]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Catch invalid memory model earlier
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 28 Jul 2016 16:20:31 +0000 (18:20 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 29 Jul 2016 09:03:24 +0000 (11:03 +0200)
Consider the following XML snippet:

    <memory model=''>
      <target>
        <size unit='KiB'>523264</size>
        <node>0</node>
      </target>
    </memory>

Whats wrong you ask? The @model attribute. This should result in
an error thrown into users faces during virDomainDefine phase.
Except it doesn't. The XML validation catches this error, but if
users chose to ignore that, they will end up with invalid XML.
Well, they won't be able to start the machine - that's when error
is produced currently. But it would be nice if we could catch the
error like this earlier.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/domain_conf.c
src/qemu/qemu_command.c
src/qemu/qemu_domain.c

index c1ddb5a09d91bfa323762f9d27e0904dddccf9f3..a56e0f5d167ce8efbc6432a9d21c7288c8d791a8 100644 (file)
@@ -13215,7 +13215,7 @@ virDomainMemoryDefParseXML(xmlNodePtr memdevNode,
         goto error;
     }
 
-    if ((def->model = virDomainMemoryModelTypeFromString(tmp)) < 0) {
+    if ((def->model = virDomainMemoryModelTypeFromString(tmp)) <= 0) {
         virReportError(VIR_ERR_XML_ERROR,
                        _("invalid memory model '%s'"), tmp);
         goto error;
index c4da8b594acbaa75c7cf124c3a16c9f2e5116bb2..5325f48dbbfa5b29bd7078bf095a0f2dfa9144b3 100644 (file)
@@ -3397,8 +3397,6 @@ qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem)
 
     case VIR_DOMAIN_MEMORY_MODEL_NONE:
     case VIR_DOMAIN_MEMORY_MODEL_LAST:
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("invalid memory device type"));
         break;
 
     }
index b3ca993f43c91c51911368cb67fb1739adb3f4ba..9b439df3b3a8d3630104421e4bce80f7720a6cb0 100644 (file)
@@ -5183,8 +5183,6 @@ qemuDomainDefValidateMemoryHotplugDevice(const virDomainMemoryDef *mem,
 
     case VIR_DOMAIN_MEMORY_MODEL_NONE:
     case VIR_DOMAIN_MEMORY_MODEL_LAST:
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("invalid memory device type"));
         return -1;
     }