提交 6385c8c1 编写于 作者: A Andrea Bolognani

conf: Introduce VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE

This is the first step in getting rid of the assumption that
isa-serial is the default target type for serial devices.
Signed-off-by: NAndrea Bolognani <abologna@redhat.com>
Reviewed-by: NPavel Hrdina <phrdina@redhat.com>
上级 2628afc1
...@@ -448,6 +448,7 @@ VIR_ENUM_IMPL(virDomainChrDeviceState, VIR_DOMAIN_CHR_DEVICE_STATE_LAST, ...@@ -448,6 +448,7 @@ VIR_ENUM_IMPL(virDomainChrDeviceState, VIR_DOMAIN_CHR_DEVICE_STATE_LAST,
VIR_ENUM_IMPL(virDomainChrSerialTarget, VIR_ENUM_IMPL(virDomainChrSerialTarget,
VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST, VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST,
"none",
"isa-serial", "isa-serial",
"usb-serial", "usb-serial",
"pci-serial") "pci-serial")
...@@ -4023,7 +4024,7 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def) ...@@ -4023,7 +4024,7 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def)
/* modify it to be a serial port */ /* modify it to be a serial port */
def->serials[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; def->serials[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
def->serials[0]->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA; def->serials[0]->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE;
def->serials[0]->target.port = 0; def->serials[0]->target.port = 0;
} else { } else {
/* if the console source doesn't match */ /* if the console source doesn't match */
...@@ -4047,7 +4048,8 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def) ...@@ -4047,7 +4048,8 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def)
def->serials[0]->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL) { def->serials[0]->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL) {
switch ((virDomainChrSerialTargetType) def->serials[0]->targetType) { switch ((virDomainChrSerialTargetType) def->serials[0]->targetType) {
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA: { case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE: {
/* Create a stub console to match the serial port. /* Create a stub console to match the serial port.
* console[0] either does not exist * console[0] either does not exist
...@@ -11493,7 +11495,7 @@ virDomainChrDefaultTargetType(int devtype) ...@@ -11493,7 +11495,7 @@ virDomainChrDefaultTargetType(int devtype)
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE; return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE;
case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL:
return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA; return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE;
case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL:
case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST: case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST:
......
...@@ -1077,7 +1077,8 @@ typedef enum { ...@@ -1077,7 +1077,8 @@ typedef enum {
} virDomainChrDeviceType; } virDomainChrDeviceType;
typedef enum { typedef enum {
VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA = 0, VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE = 0,
VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA,
VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB, VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB,
VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI, VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI,
......
...@@ -9259,6 +9259,14 @@ qemuChrIsPlatformDevice(const virDomainDef *def, ...@@ -9259,6 +9259,14 @@ qemuChrIsPlatformDevice(const virDomainDef *def,
return true; return true;
} }
/* If we got all the way here and we're still stuck with the default
* target type for a serial device, it means we have no clue what kind of
* device we're talking about and we must treat it as a platform device. */
if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE) {
return true;
}
return false; return false;
} }
...@@ -10407,7 +10415,12 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, ...@@ -10407,7 +10415,12 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
} }
break; break;
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
/* Except from _LAST, which is just a guard value and will never
* be used, all of the above are platform devices, which means
* qemuBuildSerialCommandLine() will have taken the appropriate
* branch and we will not have ended up here. */
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Invalid target type for serial device")); _("Invalid target type for serial device"));
goto error; goto error;
......
...@@ -4099,6 +4099,27 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr, ...@@ -4099,6 +4099,27 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr,
chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO; chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO;
} }
/* Historically, isa-serial and the default matched, so in order to
* maintain backwards compatibility we map them here. The actual default
* will be picked below based on the architecture and machine type. */
if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA) {
chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE;
}
/* 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)) {
/* Setting TYPE_ISA here is just a temporary hack to reduce test
* suite churn. Later on we will have a proper serial type for
* pSeries and this line will be updated accordingly. */
chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA;
}
}
/* clear auto generated unix socket path for inactive definitions */ /* clear auto generated unix socket path for inactive definitions */
if (parseFlags & VIR_DOMAIN_DEF_PARSE_INACTIVE) { if (parseFlags & VIR_DOMAIN_DEF_PARSE_INACTIVE) {
if (qemuDomainChrDefDropDefaultPath(chr, driver) < 0) if (qemuDomainChrDefDropDefaultPath(chr, driver) < 0)
......
...@@ -782,6 +782,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, ...@@ -782,6 +782,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST: case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册