From: Marc-André Lureau <marcandre.lureau(a)redhat.com>
Like a Spice port, a dbus serial must specify an associated channel name.
Signed-off-by: Marc-André Lureau <marcandre.lureau(a)redhat.com>
---
src/conf/domain_conf.c | 25 +++++++++++
src/conf/domain_conf.h | 4 ++
src/conf/domain_validate.c | 32 ++++++++++----
src/conf/schemas/domaincommon.rng | 1 +
src/qemu/qemu_command.c | 3 ++
src/qemu/qemu_monitor_json.c | 1 +
src/qemu/qemu_process.c | 1 +
src/qemu/qemu_validate.c | 1 +
src/security/security_dac.c | 2 +
.../graphics-dbus-chardev.xml | 43 +++++++++++++++++++
.../graphics-dbus-chardev.xml | 1 +
tests/qemuxml2xmltest.c | 3 ++
tests/testutilsqemu.c | 1 +
13 files changed, 109 insertions(+), 9 deletions(-)
create mode 100644 tests/qemuxml2argvdata/graphics-dbus-chardev.xml
create mode 120000 tests/qemuxml2xmloutdata/graphics-dbus-chardev.xml
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fbefba6200..bde39fd6b2 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -716,6 +716,7 @@ VIR_ENUM_IMPL(virDomainChr,
"spiceport",
"nmdm",
"qemu-vdagent",
+ "dbus",
);
VIR_ENUM_IMPL(virDomainChrTcpProtocol,
@@ -2711,6 +2712,7 @@ virDomainChrSourceDefGetPath(virDomainChrSourceDef *chr)
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT:
+ case VIR_DOMAIN_CHR_TYPE_DBUS:
case VIR_DOMAIN_CHR_TYPE_LAST:
return NULL;
}
@@ -2754,6 +2756,10 @@ virDomainChrSourceDefClear(virDomainChrSourceDef *def)
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
VIR_FREE(def->data.spiceport.channel);
break;
+
+ case VIR_DOMAIN_CHR_TYPE_DBUS:
+ VIR_FREE(def->data.dbus.channel);
+ break;
}
VIR_FREE(def->logfile);
@@ -2825,6 +2831,10 @@ virDomainChrSourceDefCopy(virDomainChrSourceDef *dest,
dest->data.qemuVdagent.mouse = src->data.qemuVdagent.mouse;
break;
+ case VIR_DOMAIN_CHR_TYPE_DBUS:
+ dest->data.dbus.channel = g_strdup(src->data.dbus.channel);
+ break;
+
case VIR_DOMAIN_CHR_TYPE_NULL:
case VIR_DOMAIN_CHR_TYPE_VC:
case VIR_DOMAIN_CHR_TYPE_STDIO:
@@ -2909,6 +2919,12 @@ virDomainChrSourceDefIsEqual(const virDomainChrSourceDef *src,
case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT:
return src->data.qemuVdagent.clipboard == tgt->data.qemuVdagent.clipboard
&&
src->data.qemuVdagent.mouse == tgt->data.qemuVdagent.mouse;
+ break;
+
+ case VIR_DOMAIN_CHR_TYPE_DBUS:
+ return STREQ_NULLABLE(src->data.dbus.channel,
+ tgt->data.dbus.channel);
+ break;
case VIR_DOMAIN_CHR_TYPE_NULL:
case VIR_DOMAIN_CHR_TYPE_VC:
@@ -11342,6 +11358,10 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef *def,
def->data.spiceport.channel = virXMLPropString(sources[0],
"channel");
break;
+ case VIR_DOMAIN_CHR_TYPE_DBUS:
+ def->data.dbus.channel = virXMLPropString(sources[0],
"channel");
+ break;
+
case VIR_DOMAIN_CHR_TYPE_NMDM:
def->data.nmdm.master = virXMLPropString(sources[0], "master");
def->data.nmdm.slave = virXMLPropString(sources[0], "slave");
@@ -25197,6 +25217,11 @@ virDomainChrSourceDefFormat(virBuffer *buf,
virBufferEscapeString(buf, "<source channel='%s'/>\n",
def->data.spiceport.channel);
break;
+
+ case VIR_DOMAIN_CHR_TYPE_DBUS:
+ virBufferEscapeString(buf, "<source channel='%s'/>\n",
+ def->data.dbus.channel);
+ break;
}
if (def->logfile) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index db50e552b0..92bab257fa 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1242,6 +1242,7 @@ typedef enum {
VIR_DOMAIN_CHR_TYPE_SPICEPORT,
VIR_DOMAIN_CHR_TYPE_NMDM,
VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT,
+ VIR_DOMAIN_CHR_TYPE_DBUS,
VIR_DOMAIN_CHR_TYPE_LAST
} virDomainChrType;
@@ -1321,6 +1322,9 @@ struct _virDomainChrSourceDef {
virDomainMouseMode mouse;
virTristateBool clipboard;
} qemuVdagent;
+ struct {
+ char *channel;
+ } dbus;
} data;
char *logfile;
virTristateSwitch logappend;
diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index ba474ee8c0..627c366fe9 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -909,6 +909,24 @@ virDomainDiskDefValidate(const virDomainDef *def,
#define SERIAL_CHANNEL_NAME_CHARS \
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-."
+
+static int
+virDomainChrSourceDefValidateChannelName(const char *name)
+{
+ if (!name) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Missing source channel attribute for char device"));
+ return -1;
+ }
+ if (strspn(name, SERIAL_CHANNEL_NAME_CHARS) < strlen(name)) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("Invalid character in source channel for char
device"));
+ return -1;
+ }
+
+ return 0;
+}
+
static int
virDomainChrSourceDefValidate(const virDomainChrSourceDef *src_def,
const virDomainChrDef *chr_def,
@@ -995,17 +1013,13 @@ virDomainChrSourceDefValidate(const virDomainChrSourceDef
*src_def,
break;
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
- if (!src_def->data.spiceport.channel) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("Missing source channel attribute for char
device"));
+ if (virDomainChrSourceDefValidateChannelName(src_def->data.spiceport.channel)
< 0)
return -1;
- }
- if (strspn(src_def->data.spiceport.channel,
- SERIAL_CHANNEL_NAME_CHARS) <
strlen(src_def->data.spiceport.channel)) {
- virReportError(VIR_ERR_INVALID_ARG, "%s",
- _("Invalid character in source channel for char
device"));
+ break;
+
+ case VIR_DOMAIN_CHR_TYPE_DBUS:
+ if (virDomainChrSourceDefValidateChannelName(src_def->data.dbus.channel) <
0)
return -1;
- }
break;
}
diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng
index 6c210f6e78..fc7c987af5 100644
--- a/src/conf/schemas/domaincommon.rng
+++ b/src/conf/schemas/domaincommon.rng
@@ -4561,6 +4561,7 @@
<value>spiceport</value>
<value>nmdm</value>
<value>qemu-vdagent</value>
+ <value>dbus</value>
</choice>
</define>
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 9367eb4dc6..9ff2d1b0e0 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1443,6 +1443,7 @@ qemuBuildChardevStr(const virDomainChrSourceDef *dev,
}
break;
+ case VIR_DOMAIN_CHR_TYPE_DBUS:
case VIR_DOMAIN_CHR_TYPE_NMDM:
case VIR_DOMAIN_CHR_TYPE_LAST:
default:
@@ -1528,6 +1529,7 @@ qemuBuildChardevCommand(virCommand *cmd,
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT:
+ case VIR_DOMAIN_CHR_TYPE_DBUS:
break;
case VIR_DOMAIN_CHR_TYPE_NMDM:
@@ -8713,6 +8715,7 @@ qemuInterfaceVhostuserConnect(virCommand *cmd,
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
case VIR_DOMAIN_CHR_TYPE_NMDM:
case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT:
+ case VIR_DOMAIN_CHR_TYPE_DBUS:
case VIR_DOMAIN_CHR_TYPE_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("vhost-user type '%s' not supported"),
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index d9f93bd2fa..afa81d1b04 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6847,6 +6847,7 @@ qemuMonitorJSONAttachCharDevGetProps(const char *chrID,
break;
}
+ case VIR_DOMAIN_CHR_TYPE_DBUS:
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
case VIR_DOMAIN_CHR_TYPE_PIPE:
case VIR_DOMAIN_CHR_TYPE_STDIO:
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 4751f60d74..f4ffb51b27 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -6867,6 +6867,7 @@ qemuProcessPrepareHostBackendChardevOne(virDomainDeviceDef *dev,
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT:
+ case VIR_DOMAIN_CHR_TYPE_DBUS:
break;
case VIR_DOMAIN_CHR_TYPE_FILE: {
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index be6b2c508b..9b6245e6d7 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -2015,6 +2015,7 @@ qemuValidateDomainChrSourceDef(const virDomainChrSourceDef *def,
case VIR_DOMAIN_CHR_TYPE_STDIO:
case VIR_DOMAIN_CHR_TYPE_UDP:
case VIR_DOMAIN_CHR_TYPE_NMDM:
+ case VIR_DOMAIN_CHR_TYPE_DBUS:
case VIR_DOMAIN_CHR_TYPE_LAST:
break;
}
diff --git a/src/security/security_dac.c b/src/security/security_dac.c
index 5b840f4225..69c462de8b 100644
--- a/src/security/security_dac.c
+++ b/src/security/security_dac.c
@@ -1556,6 +1556,7 @@ virSecurityDACSetChardevLabelHelper(virSecurityManager *mgr,
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
case VIR_DOMAIN_CHR_TYPE_NMDM:
case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT:
+ case VIR_DOMAIN_CHR_TYPE_DBUS:
case VIR_DOMAIN_CHR_TYPE_LAST:
break;
}
@@ -1641,6 +1642,7 @@ virSecurityDACRestoreChardevLabelHelper(virSecurityManager *mgr,
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
case VIR_DOMAIN_CHR_TYPE_NMDM:
case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT:
+ case VIR_DOMAIN_CHR_TYPE_DBUS:
case VIR_DOMAIN_CHR_TYPE_LAST:
break;
}
diff --git a/tests/qemuxml2argvdata/graphics-dbus-chardev.xml
b/tests/qemuxml2argvdata/graphics-dbus-chardev.xml
new file mode 100644
index 0000000000..d2ca208bd9
--- /dev/null
+++ b/tests/qemuxml2argvdata/graphics-dbus-chardev.xml
@@ -0,0 +1,43 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <serial type='dbus'>
+ <source channel='org.qemu.console.serial.0'/>
+ <target type='isa-serial' port='1'>
+ <model name='isa-serial'/>
+ </target>
+ </serial>
+ <console type='dbus'>
+ <source channel='org.qemu.console.serial.0'/>
+ <target type='serial' port='1'/>
+ </console>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <graphics type='dbus' p2p='yes'/>
+ <video>
+ <model type='cirrus' vram='16384' heads='1'
primary='yes'/>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x02' function='0x0'/>
+ </video>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/graphics-dbus-chardev.xml
b/tests/qemuxml2xmloutdata/graphics-dbus-chardev.xml
new file mode 120000
index 0000000000..85dabfad76
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/graphics-dbus-chardev.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/graphics-dbus-chardev.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index eb4e070f9e..c16ce75e14 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -413,6 +413,9 @@ mymain(void)
QEMU_CAPS_DEVICE_CIRRUS_VGA,
QEMU_CAPS_DISPLAY_DBUS,
QEMU_CAPS_AUDIODEV);
+ DO_TEST("graphics-dbus-chardev",
+ QEMU_CAPS_DEVICE_CIRRUS_VGA,
+ QEMU_CAPS_DISPLAY_DBUS);
DO_TEST_CAPS_ARCH_LATEST("default-video-type-aarch64",
"aarch64");
DO_TEST_CAPS_ARCH_LATEST("default-video-type-ppc64", "ppc64");
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 7f6d9ee06f..5ae6daf053 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -1057,6 +1057,7 @@ testQemuPrepareHostBackendChardevOne(virDomainDeviceDef *dev,
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT:
+ case VIR_DOMAIN_CHR_TYPE_DBUS:
break;
case VIR_DOMAIN_CHR_TYPE_FILE:
--
2.36.1