[libvirt] [PATCH 03/12] Introduce /domain/cpu/@check XML attribute

Ján Tomko jtomko at redhat.com
Wed Mar 15 16:34:24 UTC 2017


On Tue, Mar 14, 2017 at 05:57:42PM +0100, Jiri Denemark wrote:
>The attribute can be used to request a specific way of checking whether
>the virtual CPU matches created by the hypervisor matches the
>specification in domain XML.
>
>Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
>---
> docs/formatdomain.html.in     | 30 ++++++++++++++++++++++++++++++
> docs/schemas/cputypes.rng     | 10 ++++++++++
> docs/schemas/domaincommon.rng |  3 +++
> src/conf/cpu_conf.c           | 30 ++++++++++++++++++++++++++++++
> src/conf/cpu_conf.h           | 12 ++++++++++++
> src/conf/domain_conf.c        | 21 +++++++++++++++++++++
> 6 files changed, 106 insertions(+)
>

>diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
>index cc3fbf0a4..507f630dc 100644
>--- a/src/conf/cpu_conf.h
>+++ b/src/conf/cpu_conf.h
>@@ -98,6 +109,7 @@ struct _virCPUDef {
>     int type;           /* enum virCPUType */
>     int mode;           /* enum virCPUMode */
>     int match;          /* enum virCPUMatch */
>+    int check;          /* virCPUCheck */

It would be nicer to declare this as virCPUCheck check...

>     virArch arch;
>     char *model;
>     char *vendor_id;    /* vendor id returned by CPUID in the guest */
>diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
>index 2724fa30a..90accaea7 100644
>--- a/src/conf/cpu_conf.c
>+++ b/src/conf/cpu_conf.c
>@@ -294,6 +302,18 @@ virCPUDefParseXML(xmlNodePtr node,
>                 goto error;
>             }
>         }
>+
>+        if ((check = virXMLPropString(node, "check"))) {
>+            def->check = virCPUCheckTypeFromString(check);
>+            VIR_FREE(check);
>+
>+            if (def->check < 0) {

... which would require a temporary int variable for this comparison.

>+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
>+                               _("Invalid check attribute for CPU "
>+                                 "specification"));
>+                goto error;
>+            }
>+        }
>     }
>
>     if (def->type == VIR_CPU_TYPE_HOST) {
>@@ -532,6 +552,16 @@ virCPUDefFormatBufFull(virBufferPtr buf,
>             }
>             virBufferAsprintf(&attributeBuf, " match='%s'", tmp);
>         }
>+
>+        if (def->check) {
>+            if (!(tmp = virCPUCheckTypeToString(def->check))) {
>+                virReportError(VIR_ERR_INTERNAL_ERROR,
>+                               _("Unexpected CPU check policy %d"),

We validated the value in the parser. I don't think we need to waste
translators' time with translatable strings in dead code.

Jan

>+                               def->check);
>+                goto cleanup;
>+            }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170315/ffb98b7f/attachment-0001.sig>


More information about the libvir-list mailing list