[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH v2 08/10] conf: Move disk info validator to the domain conf validator



Since it will not be called from outside of conf we can unexport it too
if we move it to the appropriate place.

Test suite change is necessary since the error will be reported sooner
now.
---
 src/conf/domain_conf.c   | 45 ++++++++++++++++++++++++---------------------
 src/conf/domain_conf.h   |  6 ++----
 src/libvirt_private.syms |  1 -
 src/qemu/qemu_process.c  | 11 +++--------
 tests/qemuxml2argvtest.c |  6 +++---
 5 files changed, 32 insertions(+), 37 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b8a6901..987b2fe 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4580,8 +4580,29 @@ virDomainDefValidateDeviceIterator(virDomainDefPtr def,


 static int
-virDomainDefValidateInternal(const virDomainDef *def ATTRIBUTE_UNUSED)
+virDomainDefCheckDuplicateDiskInfo(const virDomainDef *def)
 {
+    size_t i;
+    size_t j;
+
+    for (i = 0; i < def->ndisks; i++) {
+        for (j = i + 1; j < def->ndisks; j++) {
+            if (virDomainDiskDefCheckDuplicateInfo(def->disks[i],
+                                                   def->disks[j]) < 0)
+                return -1;
+        }
+    }
+
+    return 0;
+}
+
+
+static int
+virDomainDefValidateInternal(const virDomainDef *def)
+{
+    if (virDomainDefCheckDuplicateDiskInfo(def) < 0)
+        return -1;
+
     return 0;
 }

@@ -24571,8 +24592,8 @@ virDomainDefNeedsPlacementAdvice(virDomainDefPtr def)


 int
-virDomainDiskDefCheckDuplicateInfo(virDomainDiskDefPtr a,
-                                   virDomainDiskDefPtr b)
+virDomainDiskDefCheckDuplicateInfo(const virDomainDiskDef *a,
+                                   const virDomainDiskDef *b)
 {
     if (STREQ(a->dst, b->dst)) {
         virReportError(VIR_ERR_XML_ERROR,
@@ -24601,24 +24622,6 @@ virDomainDiskDefCheckDuplicateInfo(virDomainDiskDefPtr a,
 }


-int
-virDomainDefCheckDuplicateDiskInfo(virDomainDefPtr def)
-{
-    size_t i;
-    size_t j;
-
-    for (i = 0; i < def->ndisks; i++) {
-        for (j = i + 1; j < def->ndisks; j++) {
-            if (virDomainDiskDefCheckDuplicateInfo(def->disks[i],
-                                                   def->disks[j]) < 0)
-                return -1;
-        }
-    }
-
-    return 0;
-}
-
-
 /**
  * virDomainDefHasMemballoon:
  * @def: domain definition
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 215235f..5c900bb 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3068,11 +3068,9 @@ virDomainParseMemory(const char *xpath,
 bool virDomainDefNeedsPlacementAdvice(virDomainDefPtr def)
     ATTRIBUTE_NONNULL(1);

-int virDomainDiskDefCheckDuplicateInfo(virDomainDiskDefPtr a,
-                                       virDomainDiskDefPtr b)
+int virDomainDiskDefCheckDuplicateInfo(const virDomainDiskDef *a,
+                                       const virDomainDiskDef *b)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
-int virDomainDefCheckDuplicateDiskInfo(virDomainDefPtr def)
-    ATTRIBUTE_NONNULL(1);

 int virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
                                      int maplen,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 9b9bfab..02a957f 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -207,7 +207,6 @@ virDomainDefAddController;
 virDomainDefAddImplicitDevices;
 virDomainDefAddUSBController;
 virDomainDefCheckABIStability;
-virDomainDefCheckDuplicateDiskInfo;
 virDomainDefClearCCWAddresses;
 virDomainDefClearDeviceAliases;
 virDomainDefClearPCIAddresses;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 068cb0e..7fc4e80 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4303,14 +4303,9 @@ qemuProcessStartValidateXML(virQEMUDriverPtr driver,
     /* checks below should not be executed when starting a qemu process for a
      * VM that was running before (migration, snapshots, save). It's more
      * important to start such VM than keep the configuration clean */
-    if ((flags & VIR_QEMU_PROCESS_START_NEW)) {
-        if (virDomainDefValidate(vm->def, caps, 0, driver->xmlopt) < 0)
-            return -1;
-
-        if (virDomainDefCheckDuplicateDiskInfo(vm->def) < 0)
-            return -1;
-    }
-
+    if ((flags & VIR_QEMU_PROCESS_START_NEW) &&
+        virDomainDefValidate(vm->def, caps, 0, driver->xmlopt) < 0)
+        return -1;

     if (vm->def->mem.min_guarantee) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index db42b7b..adec2f0 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -876,9 +876,9 @@ mymain(void)
     DO_TEST("disk-drive-discard",
             QEMU_CAPS_DRIVE_DISCARD);
     DO_TEST("disk-snapshot", NONE);
-    DO_TEST_FAILURE("disk-same-targets",
-                    QEMU_CAPS_SCSI_LSI,
-                    QEMU_CAPS_DEVICE_USB_STORAGE, QEMU_CAPS_NODEFCONFIG);
+    DO_TEST_PARSE_ERROR("disk-same-targets",
+                        QEMU_CAPS_SCSI_LSI,
+                        QEMU_CAPS_DEVICE_USB_STORAGE, QEMU_CAPS_NODEFCONFIG);
     DO_TEST("event_idx",
             QEMU_CAPS_VIRTIO_BLK_EVENT_IDX,
             QEMU_CAPS_VIRTIO_NET_EVENT_IDX,
-- 
2.8.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]