]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Use VIR_ERR_DEVICE_MISSING for various coldplug messages
authorChen Hanxiao <chenhanxiao@gmail.com>
Tue, 23 Jan 2018 04:24:45 +0000 (12:24 +0800)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 1 Feb 2018 12:17:01 +0000 (07:17 -0500)
Use the DEVICE_MISSING error code when helpers fail to find
the requested device. This makes it easier for consumers to
key off the error code rather than the error message.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_driver.c

index 5eaf97a465750508b367595e0b7cb5880b8a1564..d64686df4c5f5e886313ee4603446146c33289fb 100644 (file)
@@ -8154,7 +8154,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
     case VIR_DOMAIN_DEVICE_DISK:
         disk = dev->data.disk;
         if (!(det_disk = virDomainDiskRemoveByName(vmdef, disk->dst))) {
-            virReportError(VIR_ERR_INVALID_ARG,
+            virReportError(VIR_ERR_DEVICE_MISSING,
                            _("no target device %s"), disk->dst);
             return -1;
         }
@@ -8173,7 +8173,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
     case VIR_DOMAIN_DEVICE_HOSTDEV: {
         hostdev = dev->data.hostdev;
         if ((idx = virDomainHostdevFind(vmdef, hostdev, &det_hostdev)) < 0) {
-            virReportError(VIR_ERR_INVALID_ARG, "%s",
+            virReportError(VIR_ERR_DEVICE_MISSING, "%s",
                            _("device not present in domain configuration"));
             return -1;
         }
@@ -8185,7 +8185,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
     case VIR_DOMAIN_DEVICE_LEASE:
         lease = dev->data.lease;
         if (!(det_lease = virDomainLeaseRemove(vmdef, lease))) {
-            virReportError(VIR_ERR_INVALID_ARG,
+            virReportError(VIR_ERR_DEVICE_MISSING,
                            _("Lease %s in lockspace %s does not exist"),
                            lease->key, NULLSTR(lease->lockspace));
             return -1;
@@ -8197,7 +8197,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
         cont = dev->data.controller;
         if ((idx = virDomainControllerFind(vmdef, cont->type,
                                            cont->idx)) < 0) {
-            virReportError(VIR_ERR_INVALID_ARG, "%s",
+            virReportError(VIR_ERR_DEVICE_MISSING, "%s",
                            _("device not present in domain configuration"));
             return -1;
         }
@@ -8219,7 +8219,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
         fs = dev->data.fs;
         idx = virDomainFSIndexByName(vmdef, fs->dst);
         if (idx < 0) {
-            virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+            virReportError(VIR_ERR_DEVICE_MISSING, "%s",
                            _("no matching filesystem device was found"));
             return -1;
         }
@@ -8230,7 +8230,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
 
     case VIR_DOMAIN_DEVICE_RNG:
         if ((idx = virDomainRNGFind(vmdef, dev->data.rng)) < 0) {
-            virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+            virReportError(VIR_ERR_DEVICE_MISSING, "%s",
                            _("no matching RNG device was found"));
             return -1;
         }
@@ -8241,7 +8241,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
     case VIR_DOMAIN_DEVICE_MEMORY:
         if ((idx = virDomainMemoryFindInactiveByDef(vmdef,
                                                     dev->data.memory)) < 0) {
-            virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+            virReportError(VIR_ERR_DEVICE_MISSING, "%s",
                            _("matching memory device was not found"));
             return -1;
         }
@@ -8253,7 +8253,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
     case VIR_DOMAIN_DEVICE_REDIRDEV:
         if ((idx = virDomainRedirdevDefFind(vmdef,
                                             dev->data.redirdev)) < 0) {
-            virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+            virReportError(VIR_ERR_DEVICE_MISSING, "%s",
                            _("no matching redirdev was not found"));
             return -1;
         }
@@ -8263,7 +8263,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
 
     case VIR_DOMAIN_DEVICE_SHMEM:
         if ((idx = virDomainShmemDefFind(vmdef, dev->data.shmem)) < 0) {
-            virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+            virReportError(VIR_ERR_DEVICE_MISSING, "%s",
                            _("matching shmem device was not found"));
             return -1;
         }
@@ -8274,7 +8274,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
 
     case VIR_DOMAIN_DEVICE_WATCHDOG:
         if (!vmdef->watchdog) {
-            virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+            virReportError(VIR_ERR_DEVICE_MISSING, "%s",
                            _("domain has no watchdog"));
             return -1;
         }
@@ -8284,7 +8284,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
 
     case VIR_DOMAIN_DEVICE_INPUT:
         if ((idx = virDomainInputDefFind(vmdef, dev->data.input)) < 0) {
-            virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+            virReportError(VIR_ERR_DEVICE_MISSING, "%s",
                            _("matching input device not found"));
             return -1;
         }