Now we can return early and save some indentation
---
src/qemu/qemu_process.c | 95 ++++++++++++++++++++++++++-----------------------
1 file changed, 51 insertions(+), 44 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index c087300..10e1b5a 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4497,6 +4497,56 @@ qemuProcessMakeDir(virQEMUDriverPtr driver,
}
+static void
+qemuProcessStartWarnShmem(virDomainObjPtr vm)
+{
+ size_t i;
+ bool check_shmem = false;
+ bool shmem = vm->def->nshmems;
+
+ /*
+ * For vhost-user to work, the domain has to have some type of
+ * shared memory configured. We're not the proper ones to judge
+ * whether shared hugepages or shm are enough and will be in the
+ * future, so we'll just warn in case neither is configured.
+ * Moreover failing would give the false illusion that libvirt is
+ * really checking that everything works before running the domain
+ * and not only we are unable to do that, but it's also not our
+ * aim to do so.
+ */
+ for (i = 0; i < vm->def->nnets; i++) {
+ if (virDomainNetGetActualType(vm->def->nets[i]) ==
+ VIR_DOMAIN_NET_TYPE_VHOSTUSER) {
+ check_shmem = true;
+ break;
+ }
+ }
+
+ if (!check_shmem)
+ return;
+
+ /*
+ * This check is by no means complete. We merely check
+ * whether there are *some* hugepages enabled and *some* NUMA
+ * nodes with shared memory access.
+ */
+ if (!shmem && vm->def->mem.nhugepages) {
+ for (i = 0; i < virDomainNumaGetNodeCount(vm->def->numa); i++) {
+ if (virDomainNumaGetNodeMemoryAccessMode(vm->def->numa, i) ==
+ VIR_NUMA_MEM_ACCESS_SHARED) {
+ shmem = true;
+ break;
+ }
+ }
+ }
+
+ if (!shmem) {
+ VIR_WARN("Detected vhost-user interface without any shared memory, "
+ "the interface might not be operational");
+ }
+}
+
+
/**
* qemuProcessStartValidate:
* @vm: domain object
@@ -4517,9 +4567,6 @@ qemuProcessStartValidate(virQEMUDriverPtr driver,
bool snapshot,
unsigned int flags)
{
- bool check_shmem = false;
- size_t i;
-
if (!(flags & VIR_QEMU_PROCESS_START_PRETEND)) {
if (vm->def->virtType == VIR_DOMAIN_VIRT_KVM) {
VIR_DEBUG("Checking for KVM availability");
@@ -4559,47 +4606,7 @@ qemuProcessStartValidate(virQEMUDriverPtr driver,
VIR_DEBUG("Checking for any possible (non-fatal) issues");
- /*
- * For vhost-user to work, the domain has to have some type of
- * shared memory configured. We're not the proper ones to judge
- * whether shared hugepages or shm are enough and will be in the
- * future, so we'll just warn in case neither is configured.
- * Moreover failing would give the false illusion that libvirt is
- * really checking that everything works before running the domain
- * and not only we are unable to do that, but it's also not our
- * aim to do so.
- */
- for (i = 0; i < vm->def->nnets; i++) {
- if (virDomainNetGetActualType(vm->def->nets[i]) ==
- VIR_DOMAIN_NET_TYPE_VHOSTUSER) {
- check_shmem = true;
- break;
- }
- }
-
- if (check_shmem) {
- bool shmem = vm->def->nshmems;
-
- /*
- * This check is by no means complete. We merely check
- * whether there are *some* hugepages enabled and *some* NUMA
- * nodes with shared memory access.
- */
- if (!shmem && vm->def->mem.nhugepages) {
- for (i = 0; i < virDomainNumaGetNodeCount(vm->def->numa); i++) {
- if (virDomainNumaGetNodeMemoryAccessMode(vm->def->numa, i) ==
- VIR_NUMA_MEM_ACCESS_SHARED) {
- shmem = true;
- break;
- }
- }
- }
-
- if (!shmem) {
- VIR_WARN("Detected vhost-user interface without any shared memory,
"
- "the interface might not be operational");
- }
- }
+ qemuProcessStartWarnShmem(vm);
return 0;
}
--
2.7.3
Show replies by date
And document that these specific bits are done at startup time for
back compat reasons
---
src/qemu/qemu_process.c | 43 +++++++++++++++++++++++++++++++------------
1 file changed, 31 insertions(+), 12 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 10e1b5a..8a2f65f 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4546,6 +4546,36 @@ qemuProcessStartWarnShmem(virDomainObjPtr vm)
}
}
+static int
+qemuProcessStartValidateXML(virDomainObjPtr vm,
+ virQEMUCapsPtr qemuCaps,
+ bool migration,
+ bool snapshot)
+{
+ /* The bits we validate here are XML configs that we previously
+ * accepted. We reject them at VM startup time rather than parse
+ * time so that pre-existing VMs aren't rejected and dropped from
+ * the VM list when libvirt is updated.
+ *
+ * If back compat isn't a concern, XML validation should probably
+ * be done at parse time.
+ */
+ if (qemuValidateCpuCount(vm->def, qemuCaps) < 0)
+ return -1;
+
+ if (!migration && !snapshot &&
+ virDomainDefCheckDuplicateDiskInfo(vm->def) < 0)
+ return -1;
+
+ if (vm->def->mem.min_guarantee) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Parameter 'min_guarantee' "
+ "not supported by QEMU."));
+ return -1;
+ }
+
+ return 0;
+}
/**
* qemuProcessStartValidate:
@@ -4590,20 +4620,9 @@ qemuProcessStartValidate(virQEMUDriverPtr driver,
}
- if (qemuValidateCpuCount(vm->def, qemuCaps) < 0)
- return -1;
-
- if (!migration && !snapshot &&
- virDomainDefCheckDuplicateDiskInfo(vm->def) < 0)
+ if (qemuProcessStartValidateXML(vm, qemuCaps, migration, snapshot) < 0)
return -1;
- if (vm->def->mem.min_guarantee) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("Parameter 'min_guarantee' "
- "not supported by QEMU."));
- return -1;
- }
-
VIR_DEBUG("Checking for any possible (non-fatal) issues");
qemuProcessStartWarnShmem(vm);
--
2.7.3
On Wed, Apr 20, 2016 at 05:01:22PM -0400, Cole Robinson wrote:
Now we can return early and save some indentation
---
src/qemu/qemu_process.c | 95 ++++++++++++++++++++++++++-----------------------
1 file changed, 51 insertions(+), 44 deletions(-)
ACK series
Jan