#include "ch_hostdev.h"
#include "virlog.h"
+#include "virerror.h"
+#include "virhostdev.h"
#define VIR_FROM_THIS VIR_FROM_CH
VIR_LOG_INIT("ch.ch_hostdev");
+int
+virCHHostdevPrepareDomainDevices(virCHDriver *driver,
+ virDomainDef *def,
+ unsigned int flags)
+
+{
+ if (!def->nhostdevs)
+ return 0;
+
+ if (virHostdevPreparePCIDevices(driver->hostdevMgr, CH_DRIVER_NAME,
+ def->name, def->uuid,
+ def->hostdevs, def->nhostdevs,
+ flags) < 0)
+ return -1;
+
+ return 0;
+}
+
static int
virCHDomainPrepareHostdevPCI(virDomainHostdevDef *hostdev)
{
return 0;
}
+/**
+ * virCHProcessPrepareHost:
+ * @driver: ch driver
+ * @vm: domain object
+ *
+ * This function groups all code that modifies host system to prepare
+ * environment for a domain which is about to start.
+ *
+ * This function MUST be called only after virCHProcessPrepareDomain().
+ */
+static int
+virCHProcessPrepareHost(virCHDriver *driver, virDomainObj *vm)
+{
+ unsigned int hostdev_flags = 0;
+ virCHDomainObjPrivate *priv = vm->privateData;
+ g_autoptr(virCHDriverConfig) cfg = virCHDriverGetConfig(driver);
+
+ if (virCHHostdevPrepareDomainDevices(driver, vm->def, hostdev_flags) < 0)
+ return -1;
+
+ /* Ensure no historical cgroup for this VM is lying around */
+ VIR_DEBUG("Ensuring no historical cgroup is lying around");
+ virDomainCgroupRemoveCgroup(vm, priv->cgroup, priv->machineName);
+
+ return 0;
+}
+
/**
* virCHProcessPrepareDomain:
* @vm: domain object
return -1;
}
+ if (virCHProcessPrepareHost(driver, vm) < 0)
+ return -1;
+
if (!priv->monitor) {
/* And we can get the first monitor connection now too */
if (!(priv->monitor = virCHProcessConnectMonitor(driver, vm))) {