From 38c2b707c1ccbc986574acb82eeecdbe7736218f Mon Sep 17 00:00:00 2001 From: Rafael Fonseca Date: Tue, 24 Mar 2020 17:14:34 +0100 Subject: [PATCH] test: move video default logic to driver The logic setting a device default should be in the post parse function of individual driver code. Signed-off-by: Rafael Fonseca Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 10 +--------- src/test/test_driver.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 53bc791e10..53fd13e80f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15715,18 +15715,10 @@ int virDomainVideoDefaultType(const virDomainDef *def) { switch ((virDomainVirtType)def->virtType) { - case VIR_DOMAIN_VIRT_TEST: - if (def->os.type == VIR_DOMAIN_OSTYPE_XEN || - def->os.type == VIR_DOMAIN_OSTYPE_LINUX) - return VIR_DOMAIN_VIDEO_TYPE_XEN; - else if (ARCH_IS_PPC64(def->os.arch)) - return VIR_DOMAIN_VIDEO_TYPE_VGA; - else - return VIR_DOMAIN_VIDEO_TYPE_CIRRUS; - case VIR_DOMAIN_VIRT_VBOX: return VIR_DOMAIN_VIDEO_TYPE_VBOX; + case VIR_DOMAIN_VIRT_TEST: case VIR_DOMAIN_VIRT_VMWARE: case VIR_DOMAIN_VIRT_VZ: case VIR_DOMAIN_VIRT_PARALLELS: diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 73fe1ad6ce..7759847c2d 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -407,6 +407,28 @@ testDomainObjPrivateAlloc(void *opaque) } +static int +testDomainDevicesDefPostParse(virDomainDeviceDefPtr dev G_GNUC_UNUSED, + const virDomainDef *def G_GNUC_UNUSED, + unsigned int parseFlags G_GNUC_UNUSED, + void *opaque G_GNUC_UNUSED, + void *parseOpaque G_GNUC_UNUSED) +{ + if (dev->type == VIR_DOMAIN_DEVICE_VIDEO && + dev->data.video->type == VIR_DOMAIN_VIDEO_TYPE_DEFAULT) { + if (def->os.type == VIR_DOMAIN_OSTYPE_XEN || + def->os.type == VIR_DOMAIN_OSTYPE_LINUX) + dev->data.video->type = VIR_DOMAIN_VIDEO_TYPE_XEN; + else if (ARCH_IS_PPC64(def->os.arch)) + dev->data.video->type = VIR_DOMAIN_VIDEO_TYPE_VGA; + else + dev->data.video->type = VIR_DOMAIN_VIDEO_TYPE_CIRRUS; + } + + return 0; +} + + static void testDomainObjPrivateFree(void *data) { @@ -431,6 +453,7 @@ testDriverNew(void) VIR_DOMAIN_DEF_FEATURE_USER_ALIAS | VIR_DOMAIN_DEF_FEATURE_FW_AUTOSELECT | VIR_DOMAIN_DEF_FEATURE_NET_MODEL_STRING, + .devicesPostParseCallback = testDomainDevicesDefPostParse, .defArch = VIR_ARCH_I686, }; virDomainXMLPrivateDataCallbacks privatecb = { -- GitLab