[libvirt] [PATCH v3 4/5] qemu: Use VIR_ERR_DEVICE_MISSING for various DetachDeviceConfig messages

Chen Hanxiao posted 5 patches 8 years ago
[libvirt] [PATCH v3 4/5] qemu: Use VIR_ERR_DEVICE_MISSING for various DetachDeviceConfig messages
Posted by Chen Hanxiao 8 years ago
From: Chen Hanxiao <chenhanxiao@gmail.com>

Modify OPERATION_FAILED error codes to use DEVICE_MISSING instead.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
---
 src/qemu/qemu_driver.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index a203c9297..10eebd61c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8172,7 +8172,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;
         }
@@ -8184,7 +8184,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;
@@ -8196,7 +8196,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;
         }
@@ -8218,7 +8218,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;
         }
@@ -8229,7 +8229,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;
         }
@@ -8240,7 +8240,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;
         }
@@ -8252,7 +8252,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;
         }
@@ -8262,7 +8262,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;
         }
@@ -8273,7 +8273,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;
         }
@@ -8283,7 +8283,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;
         }
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 4/5] qemu: Use VIR_ERR_DEVICE_MISSING for various DetachDeviceConfig messages
Posted by John Ferlan 8 years ago
Let's alter the commit message to be more similar to patch 3/5, e.g.:

qemu: Use VIR_ERR_DEVICE_MISSING for various coldplug messages

On 01/22/2018 11:24 PM, Chen Hanxiao wrote:
> From: Chen Hanxiao <chenhanxiao@gmail.com>
> 
> Modify OPERATION_FAILED error codes to use DEVICE_MISSING instead.

Changing this to:

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.


...

again no need to post an update, I can make the adjustment...

> 
> Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
> ---
>  src/qemu/qemu_driver.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index a203c9297..10eebd61c 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -8172,7 +8172,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
>      case VIR_DOMAIN_DEVICE_HOSTDEV: {

Any specific reason you didn't alter the VIR_DOMAIN_DEVICE_DISK error
code as well?  I can do that for you before pushing.

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

[...]

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 4/5] qemu: Use VIR_ERR_DEVICE_MISSING for various DetachDeviceConfig messages
Posted by Chen Hanxiao 8 years ago

At 2018-01-31 23:34:55, "John Ferlan" <jferlan@redhat.com> wrote:
>
>Let's alter the commit message to be more similar to patch 3/5, e.g.:
>
>qemu: Use VIR_ERR_DEVICE_MISSING for various coldplug messages
>
>On 01/22/2018 11:24 PM, Chen Hanxiao wrote:
>> From: Chen Hanxiao <chenhanxiao@gmail.com>
>> 
>> Modify OPERATION_FAILED error codes to use DEVICE_MISSING instead.
>
>Changing this to:
>
>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.
>
>
>...
>
>again no need to post an update, I can make the adjustment...
>
>> 
>> Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
>> ---
>>  src/qemu/qemu_driver.c | 20 ++++++++++----------
>>  1 file changed, 10 insertions(+), 10 deletions(-)
>> 
>> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
>> index a203c9297..10eebd61c 100644
>> --- a/src/qemu/qemu_driver.c
>> +++ b/src/qemu/qemu_driver.c
>> @@ -8172,7 +8172,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
>>      case VIR_DOMAIN_DEVICE_HOSTDEV: {
>
>Any specific reason you didn't alter the VIR_DOMAIN_DEVICE_DISK error
>code as well?  I can do that for you before pushing.
>

Ahh, my fault.
Thanks for your help.

Regards,
- Chen

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list