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>
---
docs/schemas/domaincommon.rng | 1 +
src/conf/domain_conf.c | 26 +++++++++++
src/conf/domain_conf.h | 4 ++
src/conf/domain_validate.c | 32 ++++++++++----
src/qemu/qemu_command.c | 2 +
src/qemu/qemu_monitor_json.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 ++
11 files changed, 107 insertions(+), 9 deletions(-)
create mode 100644 tests/qemuxml2argvdata/graphics-dbus-chardev.xml
create mode 120000 tests/qemuxml2xmloutdata/graphics-dbus-chardev.xml
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index a8777acf9ea8..2499b71c59dc 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4506,6 +4506,7 @@
<value>spicevmc</value>
<value>spiceport</value>
<value>nmdm</value>
+ <value>dbus</value>
</choice>
</define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3d89fed72e2d..49b5cdb7c0f3 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -701,6 +701,7 @@ VIR_ENUM_IMPL(virDomainChr,
"spicevmc",
"spiceport",
"nmdm",
+ "dbus",
);
VIR_ENUM_IMPL(virDomainChrTcpProtocol,
@@ -2681,6 +2682,7 @@ virDomainChrSourceDefGetPath(virDomainChrSourceDef *chr)
case VIR_DOMAIN_CHR_TYPE_STDIO:
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
+ case VIR_DOMAIN_CHR_TYPE_DBUS:
case VIR_DOMAIN_CHR_TYPE_LAST:
return NULL;
}
@@ -2724,6 +2726,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);
@@ -2778,7 +2784,14 @@ virDomainChrSourceDefCopy(virDomainChrSourceDef *dest,
case VIR_DOMAIN_CHR_TYPE_NMDM:
dest->data.nmdm.master = g_strdup(src->data.nmdm.master);
dest->data.nmdm.slave = g_strdup(src->data.nmdm.slave);
+ break;
+
+ case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
+ dest->data.spiceport.channel = g_strdup(src->data.spiceport.channel);
+ break;
+ case VIR_DOMAIN_CHR_TYPE_DBUS:
+ dest->data.dbus.channel = g_strdup(src->data.dbus.channel);
break;
}
@@ -2860,6 +2873,11 @@ virDomainChrSourceDefIsEqual(const virDomainChrSourceDef *src,
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
return src->data.spicevmc == tgt->data.spicevmc;
+ 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:
case VIR_DOMAIN_CHR_TYPE_STDIO:
@@ -11374,6 +11392,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");
@@ -25224,6 +25246,10 @@ virDomainChrSourceDefFormat(virBuffer *buf,
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 676d2893913e..fdf8981b3f66 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1209,6 +1209,7 @@ typedef enum {
VIR_DOMAIN_CHR_TYPE_SPICEVMC,
VIR_DOMAIN_CHR_TYPE_SPICEPORT,
VIR_DOMAIN_CHR_TYPE_NMDM,
+ VIR_DOMAIN_CHR_TYPE_DBUS,
VIR_DOMAIN_CHR_TYPE_LAST
} virDomainChrType;
@@ -1277,6 +1278,9 @@ struct _virDomainChrSourceDef {
struct {
char *channel;
} spiceport;
+ struct {
+ char *channel;
+ } dbus;
} data;
char *logfile;
virTristateSwitch logappend;
diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index c13472516fec..97b581ddb11d 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -832,6 +832,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,
@@ -917,17 +935,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/qemu/qemu_command.c b/src/qemu/qemu_command.c
index e4d39dc5b8fd..308ccbf72a1a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5297,6 +5297,7 @@ qemuBuildChrChardevStr(virLogManager *logManager,
dev->data.spiceport.channel);
break;
+ case VIR_DOMAIN_CHR_TYPE_DBUS:
case VIR_DOMAIN_CHR_TYPE_NMDM:
case VIR_DOMAIN_CHR_TYPE_LAST:
default:
@@ -8781,6 +8782,7 @@ qemuInterfaceVhostuserConnect(virQEMUDriver *driver,
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
case VIR_DOMAIN_CHR_TYPE_NMDM:
+ 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 c10ea583fd78..c0906fe70f8f 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6772,6 +6772,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_validate.c b/src/qemu/qemu_validate.c
index 0c12feb68b1f..ca34afcc7daa 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -1955,6 +1955,7 @@ qemuValidateDomainChrSourceDef(const virDomainChrSourceDef *def,
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
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 e9e316551ebb..d24f4fef1e73 100644
--- a/src/security/security_dac.c
+++ b/src/security/security_dac.c
@@ -1555,6 +1555,7 @@ virSecurityDACSetChardevLabelHelper(virSecurityManager *mgr,
case VIR_DOMAIN_CHR_TYPE_TCP:
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
case VIR_DOMAIN_CHR_TYPE_NMDM:
+ case VIR_DOMAIN_CHR_TYPE_DBUS:
case VIR_DOMAIN_CHR_TYPE_LAST:
break;
}
@@ -1639,6 +1640,7 @@ virSecurityDACRestoreChardevLabelHelper(virSecurityManager *mgr,
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
case VIR_DOMAIN_CHR_TYPE_NMDM:
+ 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 000000000000..d2ca208bd932
--- /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 000000000000..85dabfad7689
--- /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 f9eb4052517b..b23aee1389b8 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -389,6 +389,9 @@ mymain(void)
DO_TEST("graphics-dbus-clipboard",
QEMU_CAPS_DEVICE_CIRRUS_VGA,
QEMU_CAPS_DISPLAY_DBUS);
+ 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");
--
2.34.1.8.g35151cf07204