<p>
<code>target</code> can have a <code>port</code> attribute, which
specifies the port number. Ports are numbered starting from 0. There are
- usually 0, 1 or 2 serial ports.
+ usually 0, 1 or 2 serial ports. There is also an optional
+ <code>type</code> attribute <span class="since">since 1.0.2</span>
+ which has two choices for its value, one is< code>isa-serial</code>,
+ the other is <code>usb-serial</code>. If <code>type</code> is missing,
+ <code>isa-serial</code> will be used by default. For <code>usb-serial</code>
+ an optional sub-element <code><address></code> with
+ <code>type='usb'</code> can tie the device to a particular controller,
+ <a href="#elementsAddress">documented above</a>.
</p>
<h6><a name="elementCharConsole">Console</a></h6>
</attribute>
</define>
+ <define name='qemucdevSerialTgtType'>
+ <attribute name='type'>
+ <choice>
+ <value>isa-serial</value>
+ <value>usb-serial</value>
+ </choice>
+ </attribute>
+ </define>
+
<define name="qemucdevTgtDef">
<element name="target">
<interleave>
- <optional>
- <ref name="qemucdevConsoleTgtType"/>
- </optional>
+ <choice>
+ <optional>
+ <ref name="qemucdevConsoleTgtType"/>
+ </optional>
+ <optional>
+ <ref name="qemucdevSerialTgtType"/>
+ </optional>
+ </choice>
<optional>
<attribute name="port"/>
</optional>
"up",
"down")
+VIR_ENUM_IMPL(virDomainChrSerialTarget,
+ VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST,
+ "isa-serial",
+ "usb-serial")
+
VIR_ENUM_IMPL(virDomainChrChannelTarget,
VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST,
"none",
break;
case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL:
+ target = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA;
+ break;
+
case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL:
default:
/* No target type yet*/
static int
virDomainChrTargetTypeFromString(virCapsPtr caps,
- virDomainDefPtr def,
+ virDomainDefPtr vmdef,
+ virDomainChrDefPtr def,
int devtype,
const char *targetType)
{
int target = 0;
if (!targetType) {
- target = virDomainChrDefaultTargetType(caps, def, devtype);
+ target = virDomainChrDefaultTargetType(caps, vmdef, devtype);
goto out;
}
break;
case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL:
+ target = virDomainChrSerialTargetTypeFromString(targetType);
+ break;
+
case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL:
default:
/* No target type yet*/
break;
}
+ def->targetTypeAttr = true;
+
out:
ret = target;
return ret;
const char *portStr = NULL;
if ((def->targetType =
- virDomainChrTargetTypeFromString(caps, vmdef,
+ virDomainChrTargetTypeFromString(caps, vmdef, def,
def->deviceType, targetType)) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("unknown target type '%s' specified for character device"),
if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
goto error;
+ if (def->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
+ def->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB &&
+ def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+ def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("usb-serial requires address of usb type"));
+ goto error;
+ }
+
cleanup:
VIR_FREE(type);
case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE:
type = virDomainChrConsoleTargetTypeToString(targetType);
break;
+ case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL:
+ type = virDomainChrSerialTargetTypeToString(targetType);
+ break;
default:
break;
}
def->target.port);
break;
+ case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL:
+ if (def->targetTypeAttr) {
+ virBufferAsprintf(buf,
+ " <target type='%s' port='%d'/>\n",
+ virDomainChrTargetTypeToString(def->deviceType,
+ def->targetType),
+ def->target.port);
+ break;
+ }
default:
virBufferAsprintf(buf, " <target port='%d'/>\n",
def->target.port);
(n < def->nserials)) {
memcpy(&console, def->serials[n], sizeof(console));
console.deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
+ console.targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
} else {
memcpy(&console, def->consoles[n], sizeof(console));
}
VIR_DOMAIN_CHR_DEVICE_TYPE_LAST
};
+enum virDomainChrSerialTargetType {
+ VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA = 0,
+ VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB,
+
+ VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST
+};
+
enum virDomainChrChannelTargetType {
VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_NONE = 0,
VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD,
/* A complete character device, both host and domain views. */
struct _virDomainChrDef {
int deviceType;
+
+ bool targetTypeAttr;
int targetType;
union {
int port; /* parallel, serial, console */
VIR_ENUM_DECL(virDomainChrDevice)
VIR_ENUM_DECL(virDomainChrChannelTarget)
VIR_ENUM_DECL(virDomainChrConsoleTarget)
+VIR_ENUM_DECL(virDomainChrSerialTarget)
VIR_ENUM_DECL(virDomainSmartcard)
VIR_ENUM_DECL(virDomainChr)
VIR_ENUM_DECL(virDomainChrTcpProtocol)
virDomainChrDefForeach;
virDomainChrDefFree;
virDomainChrDefNew;
+virDomainChrSerialTargetTypeFromString;
+virDomainChrSerialTargetTypeToString;
virDomainChrSourceDefCopy;
virDomainChrSourceDefFree;
virDomainChrSpicevmcTypeFromString;
if (qemuBuildDeviceAddressStr(&cmd, &serial->info, caps) < 0)
goto error;
}
- } else
- virBufferAsprintf(&cmd, "isa-serial,chardev=char%s,id=%s",
+ } else {
+ virBufferAsprintf(&cmd, "%s,chardev=char%s,id=%s",
+ virDomainChrSerialTargetTypeToString(serial->targetType),
serial->info.alias, serial->info.alias);
+ if (serial->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB) {
+ if (!qemuCapsGet(caps, QEMU_CAPS_DEVICE_USB_SERIAL)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("usb-serial is not supported in this QEMU binary"));
+ goto error;
+ }
+
+ if (serial->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+ serial->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("usb-serial requires address of usb type"));
+ goto error;
+ }
+
+ if (qemuBuildDeviceAddressStr(&cmd, &serial->info, caps) < 0)
+ goto error;
+ }
+ }
+
if (virBufferError(&cmd)) {
virReportOOMError();
goto error;