[libvirt] [PATCH v2] qemu: Default hwclock source for sPAPR to RTC

Kothapally Madhu Pavan posted 1 patch 6 years, 8 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1500029753-126365-1-git-send-email-kmp@linux.vnet.ibm.com
src/qemu/qemu_domain.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
[libvirt] [PATCH v2] qemu: Default hwclock source for sPAPR to RTC
Posted by Kothapally Madhu Pavan 6 years, 8 months ago
QEMU fails to launch a sPAPR guest with clock sources other that RTC.
Internally qemu only uses RTC timer for hwclock. This patch reports
the right error message instead of qemu erroring out when any other
timer other than RTC is used.

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
---
 src/qemu/qemu_domain.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 8e7404d..b74800d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3025,6 +3025,7 @@ qemuDomainDefValidate(const virDomainDef *def,
     virQEMUCapsPtr qemuCaps = NULL;
     unsigned int topologycpus;
     int ret = -1;
+    size_t i;
 
     if (!(qemuCaps = virQEMUCapsCacheLookup(caps,
                                             driver->qemuCapsCache,
@@ -3037,6 +3038,18 @@ qemuDomainDefValidate(const virDomainDef *def,
         goto cleanup;
     }
 
+    /* Only RTC timer is supported as hwclock for sPAPR machines */
+    for (i = 0; i < def->clock.ntimers; i++) {
+        virDomainTimerDefPtr timer = def->clock.timers[i];
+        if (ARCH_IS_PPC64(def->os.arch) && timer->name != VIR_DOMAIN_TIMER_NAME_RTC) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("unsupported clock timer '%s' for %s architecture"),
+                             virDomainTimerNameTypeToString(def->clock.timers[i]->name),
+                             virArchToString(def->os.arch));
+            goto cleanup;
+        }
+    }
+
     /* On x86, UEFI requires ACPI */
     if (def->os.loader &&
         def->os.loader->type == VIR_DOMAIN_LOADER_TYPE_PFLASH &&
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2] qemu: Default hwclock source for sPAPR to RTC
Posted by Cole Robinson 6 years, 8 months ago
On 07/14/2017 06:55 AM, Kothapally Madhu Pavan wrote:
> QEMU fails to launch a sPAPR guest with clock sources other that RTC.
> Internally qemu only uses RTC timer for hwclock. This patch reports
> the right error message instead of qemu erroring out when any other
> timer other than RTC is used.
> 
> Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
> ---
>  src/qemu/qemu_domain.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 8e7404d..b74800d 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -3025,6 +3025,7 @@ qemuDomainDefValidate(const virDomainDef *def,
>      virQEMUCapsPtr qemuCaps = NULL;
>      unsigned int topologycpus;
>      int ret = -1;
> +    size_t i;
>  
>      if (!(qemuCaps = virQEMUCapsCacheLookup(caps,
>                                              driver->qemuCapsCache,
> @@ -3037,6 +3038,18 @@ qemuDomainDefValidate(const virDomainDef *def,
>          goto cleanup;
>      }
>  
> +    /* Only RTC timer is supported as hwclock for sPAPR machines */
> +    for (i = 0; i < def->clock.ntimers; i++) {
> +        virDomainTimerDefPtr timer = def->clock.timers[i];
> +        if (ARCH_IS_PPC64(def->os.arch) && timer->name != VIR_DOMAIN_TIMER_NAME_RTC) {
> +            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> +                           _("unsupported clock timer '%s' for %s architecture"),
> +                             virDomainTimerNameTypeToString(def->clock.timers[i]->name),
> +                             virArchToString(def->os.arch));
> +            goto cleanup;
> +        }
> +    }
> +
>      /* On x86, UEFI requires ACPI */
>      if (def->os.loader &&
>          def->os.loader->type == VIR_DOMAIN_LOADER_TYPE_PFLASH &&
> 

Rather than enforce this for only PPC64, you can reject hpet if the
QEMU_CAPS_NO_HPET flag isn't available, and pit if QEMU_CAPS_NO_KVM_PIT aren't
available (this is effectively non-x86, see virQEMUCapsInitQMPBasicArch, but I
think it's better this way)

- Cole

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