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 <r4f4rfs@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Rafael Fonseca 2020-03-24 17:14:34 +01:00 committed by Michal Privoznik
parent c286f2abe0
commit 38c2b707c1
2 changed files with 24 additions and 9 deletions

View File

@ -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:

View File

@ -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 = {