Allowing to have the extra undefined/default state. Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxx> --- src/conf/domain_conf.c | 41 ++++++++++++++++++++++++++--------------- src/conf/domain_conf.h | 4 ++-- src/vbox/vbox_common.c | 18 ++++++++++++------ 3 files changed, 40 insertions(+), 23 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f501f14..111c2ae 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11961,8 +11961,9 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node) { xmlNodePtr cur; virDomainVideoAccelDefPtr def; - char *accel3d = NULL; char *accel2d = NULL; + char *accel3d = NULL; + int val; cur = node->children; while (cur != NULL) { @@ -11983,21 +11984,26 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node) return NULL; if (accel3d) { - if (STREQ(accel3d, "yes")) - def->accel3d = true; - else - def->accel3d = false; - VIR_FREE(accel3d); + if ((val = virTristateBoolTypeFromString(accel3d)) <= 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown accel3d value '%s'"), accel3d); + goto end; + } + def->accel3d = val; } if (accel2d) { - if (STREQ(accel2d, "yes")) - def->accel2d = true; - else - def->accel2d = false; - VIR_FREE(accel2d); + if ((val = virTristateBoolTypeFromString(accel2d)) <= 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown accel2d value '%s'"), accel2d); + goto end; + } + def->accel2d = val; } +end: + VIR_FREE(accel2d); + VIR_FREE(accel3d); return def; } @@ -20837,10 +20843,15 @@ static void virDomainVideoAccelDefFormat(virBufferPtr buf, virDomainVideoAccelDefPtr def) { - virBufferAsprintf(buf, "<acceleration accel3d='%s'", - def->accel3d ? "yes" : "no"); - virBufferAsprintf(buf, " accel2d='%s'", - def->accel2d ? "yes" : "no"); + virBufferAsprintf(buf, "<acceleration"); + if (def->accel3d) { + virBufferAsprintf(buf, " accel3d='%s'", + virTristateBoolTypeToString(def->accel3d)); + } + if (def->accel2d) { + virBufferAsprintf(buf, " accel2d='%s'", + virTristateBoolTypeToString(def->accel2d)); + } virBufferAddLit(buf, "/>\n"); } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 40ad68c..a1a9b48 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1382,8 +1382,8 @@ typedef enum { typedef struct _virDomainVideoAccelDef virDomainVideoAccelDef; typedef virDomainVideoAccelDef *virDomainVideoAccelDefPtr; struct _virDomainVideoAccelDef { - bool accel3d; - bool accel2d; + int accel2d; /* enum virTristateBool */ + int accel3d; /* enum virTristateBool */ }; diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 4839a62..0e84f30 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -1553,11 +1553,15 @@ vboxAttachVideo(virDomainDefPtr def, IMachine *machine) VIR_DIV_UP(def->videos[0]->vram, 1024)); gVBoxAPI.UIMachine.SetMonitorCount(machine, def->videos[0]->heads); if (def->videos[0]->accel) { - gVBoxAPI.UIMachine.SetAccelerate3DEnabled(machine, - def->videos[0]->accel->accel3d); - if (gVBoxAPI.accelerate2DVideo) + if (def->videos[0]->accel->accel3d) { + gVBoxAPI.UIMachine.SetAccelerate3DEnabled(machine, + def->videos[0]->accel->accel3d == VIR_TRISTATE_BOOL_YES); + } + if (def->videos[0]->accel->accel2d && + gVBoxAPI.accelerate2DVideo) { gVBoxAPI.UIMachine.SetAccelerate2DVideoEnabled(machine, - def->videos[0]->accel->accel2d); + def->videos[0]->accel->accel2d == VIR_TRISTATE_BOOL_YES); + } } else { gVBoxAPI.UIMachine.SetAccelerate3DEnabled(machine, 0); if (gVBoxAPI.accelerate2DVideo) @@ -3277,8 +3281,10 @@ vboxDumpVideo(virDomainDefPtr def, vboxGlobalData *data ATTRIBUTE_UNUSED, def->videos[0]->vram = VRAMSize * 1024; def->videos[0]->heads = monitorCount; if (VIR_ALLOC(def->videos[0]->accel) >= 0) { - def->videos[0]->accel->accel3d = accelerate3DEnabled; - def->videos[0]->accel->accel2d = accelerate2DEnabled; + def->videos[0]->accel->accel3d = accelerate3DEnabled ? + VIR_TRISTATE_BOOL_YES : VIR_TRISTATE_BOOL_NO; + def->videos[0]->accel->accel2d = accelerate2DEnabled ? + VIR_TRISTATE_BOOL_YES : VIR_TRISTATE_BOOL_NO; } } } -- 2.5.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list