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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
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;
+            }

Attachment: signature.asc
Description: Digital signature

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

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux