[libvirt] [PATCH 1/4] qemu: cold-plug of watchdog

Michal Privoznik posted 4 patches 7 years, 8 months ago
There is a newer version of this series
[libvirt] [PATCH 1/4] qemu: cold-plug of watchdog
Posted by Michal Privoznik 7 years, 8 months ago
https://bugzilla.redhat.com/show_bug.cgi?id=1447169

With this patch users can cold plug a watchdog. Things are pretty
simple because a domain can have at most one watchdog device.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_driver.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b7824512c..583908972 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7842,6 +7842,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
     virDomainFSDefPtr fs;
     virDomainRedirdevDefPtr redirdev;
     virDomainShmemDefPtr shmem;
+    virDomainWatchdogDefPtr watchdog;
 
     switch ((virDomainDeviceType) dev->type) {
     case VIR_DOMAIN_DEVICE_DISK:
@@ -7978,10 +7979,20 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
         dev->data.shmem = NULL;
         break;
 
+    case VIR_DOMAIN_DEVICE_WATCHDOG:
+        watchdog = dev->data.watchdog;
+        if (vmdef->watchdog) {
+            virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                           _("domain already has a watchdog"));
+            return -1;
+        }
+        vmdef->watchdog = watchdog;
+        dev->data.watchdog = NULL;
+        break;
+
     case VIR_DOMAIN_DEVICE_INPUT:
     case VIR_DOMAIN_DEVICE_SOUND:
     case VIR_DOMAIN_DEVICE_VIDEO:
-    case VIR_DOMAIN_DEVICE_WATCHDOG:
     case VIR_DOMAIN_DEVICE_GRAPHICS:
     case VIR_DOMAIN_DEVICE_HUB:
     case VIR_DOMAIN_DEVICE_SMARTCARD:
-- 
2.13.5

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/4] qemu: cold-plug of watchdog
Posted by John Ferlan 7 years, 8 months ago

On 09/05/2017 07:45 AM, Michal Privoznik wrote:
> https://bugzilla.redhat.com/show_bug.cgi?id=1447169
> 
> With this patch users can cold plug a watchdog. Things are pretty
> simple because a domain can have at most one watchdog device.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/qemu/qemu_driver.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index b7824512c..583908972 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -7842,6 +7842,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
>      virDomainFSDefPtr fs;
>      virDomainRedirdevDefPtr redirdev;
>      virDomainShmemDefPtr shmem;
> +    virDomainWatchdogDefPtr watchdog;
>  
>      switch ((virDomainDeviceType) dev->type) {
>      case VIR_DOMAIN_DEVICE_DISK:
> @@ -7978,10 +7979,20 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
>          dev->data.shmem = NULL;
>          break;
>  
> +    case VIR_DOMAIN_DEVICE_WATCHDOG:
> +        watchdog = dev->data.watchdog;
> +        if (vmdef->watchdog) {
> +            virReportError(VIR_ERR_OPERATION_INVALID, "%s",
> +                           _("domain already has a watchdog"));
> +            return -1;
> +        }
> +        vmdef->watchdog = watchdog;
> +        dev->data.watchdog = NULL;

Couldn't this just simply be:

    VIR_STEAL_PTR(vmdef->watchdog, dev->data.watchdog);

the local @watchdog wouldn't be necessary then either...

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

John

> +        break;
> +
>      case VIR_DOMAIN_DEVICE_INPUT:
>      case VIR_DOMAIN_DEVICE_SOUND:
>      case VIR_DOMAIN_DEVICE_VIDEO:
> -    case VIR_DOMAIN_DEVICE_WATCHDOG:
>      case VIR_DOMAIN_DEVICE_GRAPHICS:
>      case VIR_DOMAIN_DEVICE_HUB:
>      case VIR_DOMAIN_DEVICE_SMARTCARD:
> 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/4] qemu: cold-plug of watchdog
Posted by Michal Privoznik 7 years, 8 months ago
On 09/12/2017 03:26 PM, John Ferlan wrote:
> 
> 
> On 09/05/2017 07:45 AM, Michal Privoznik wrote:
>> https://bugzilla.redhat.com/show_bug.cgi?id=1447169
>>
>> With this patch users can cold plug a watchdog. Things are pretty
>> simple because a domain can have at most one watchdog device.
>>
>> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>> ---
>>  src/qemu/qemu_driver.c | 13 ++++++++++++-
>>  1 file changed, 12 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
>> index b7824512c..583908972 100644
>> --- a/src/qemu/qemu_driver.c
>> +++ b/src/qemu/qemu_driver.c
>> @@ -7842,6 +7842,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
>>      virDomainFSDefPtr fs;
>>      virDomainRedirdevDefPtr redirdev;
>>      virDomainShmemDefPtr shmem;
>> +    virDomainWatchdogDefPtr watchdog;
>>  
>>      switch ((virDomainDeviceType) dev->type) {
>>      case VIR_DOMAIN_DEVICE_DISK:
>> @@ -7978,10 +7979,20 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
>>          dev->data.shmem = NULL;
>>          break;
>>  
>> +    case VIR_DOMAIN_DEVICE_WATCHDOG:
>> +        watchdog = dev->data.watchdog;
>> +        if (vmdef->watchdog) {
>> +            virReportError(VIR_ERR_OPERATION_INVALID, "%s",
>> +                           _("domain already has a watchdog"));
>> +            return -1;
>> +        }
>> +        vmdef->watchdog = watchdog;
>> +        dev->data.watchdog = NULL;
> 
> Couldn't this just simply be:
> 
>     VIR_STEAL_PTR(vmdef->watchdog, dev->data.watchdog);
> 
> the local @watchdog wouldn't be necessary then either...

Oh right. For some reason I can not get used to these macros.

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

Fixed and pushed, thanks.

Michal

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