提交 806ae499 编写于 作者: M Marc-André Lureau 提交者: Michal Privoznik

domain: replace bool accel{2d, 3d} with a tristate

Allowing to have the extra undefined/default state.
Signed-off-by: NMarc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 56a4fe28
......@@ -12007,8 +12007,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) {
......@@ -12026,24 +12027,29 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node)
return NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
goto cleanup;
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 cleanup;
}
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 cleanup;
}
def->accel2d = val;
}
cleanup:
VIR_FREE(accel2d);
VIR_FREE(accel3d);
return def;
}
......@@ -20873,10 +20879,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");
virBufferAddLit(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");
}
......
......@@ -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 */
};
......
......@@ -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;
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册