Factor out the existing code. Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx> --- src/qemu/qemu_domain.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 5b93529655..b3e63b3648 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4292,6 +4292,26 @@ qemuDomainForbidLegacyUSBController(const virDomainDef *def) } +static int +qemuDomainDefaultSerialType(const virDomainDef *def) +{ + if (ARCH_IS_X86(def->os.arch)) + return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA; + + if (qemuDomainIsPSeries(def)) + return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO; + + if (ARCH_IS_S390(def->os.arch)) + return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP; + + if (qemuDomainIsARMVirt(def) || + qemuDomainIsRISCVVirt(def)) + return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM; + + return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE; +} + + static int qemuDomainDefAddDefaultDevices(virQEMUDriver *driver, virDomainDef *def, @@ -5872,15 +5892,7 @@ qemuDomainChrDefPostParse(virDomainChrDef *chr, /* Set the default serial type */ if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE) { - if (ARCH_IS_X86(def->os.arch)) { - chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA; - } else if (qemuDomainIsPSeries(def)) { - chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO; - } else if (qemuDomainIsARMVirt(def) || qemuDomainIsRISCVVirt(def)) { - chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM; - } else if (ARCH_IS_S390(def->os.arch)) { - chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP; - } + chr->targetType = qemuDomainDefaultSerialType(def); } /* Set the default target model */ -- 2.43.0 _______________________________________________ Devel mailing list -- devel@xxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx