]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: disk: Extract checking of removable status
authorPeter Krempa <pkrempa@redhat.com>
Wed, 20 Apr 2016 15:19:04 +0000 (17:19 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 21 Apr 2016 15:04:06 +0000 (17:04 +0200)
src/conf/domain_conf.c

index f76a8b7f87b4a8d1dde761b3bb865a873485496d..bcd19d8419547f2f659408c766cca17c3342917c 100644 (file)
@@ -6941,6 +6941,13 @@ virDomainDiskDefValidate(const virDomainDiskDef *def)
         return -1;
     }
 
+    if (def->removable != VIR_TRISTATE_SWITCH_ABSENT &&
+        def->bus != VIR_DOMAIN_DISK_BUS_USB) {
+        virReportError(VIR_ERR_XML_ERROR, "%s",
+                       _("removable is only valid for usb disks"));
+        return -1;
+    }
+
     return 0;
 }
 
@@ -7423,12 +7430,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
                            _("unknown disk removable status '%s'"), removable);
             goto error;
         }
-
-        if (def->bus != VIR_DOMAIN_DISK_BUS_USB) {
-            virReportError(VIR_ERR_XML_ERROR, "%s",
-                           _("removable is only valid for usb disks"));
-            goto error;
-        }
     }
 
     if (devaddr) {