From: Marc-André Lureau <marcandre.lureau(a)redhat.com>
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 | 10 +++++
src/qemu/qemu_monitor_json.c | 1 +
src/qemu/qemu_validate.c | 1 +
src/security/security_dac.c | 2 +
.../graphics-dbus-chardev.args | 33 ++++++++++++++++
.../graphics-dbus-chardev.xml | 38 +++++++++++++++++++
tests/qemuxml2argvtest.c | 4 ++
11 files changed, 143 insertions(+), 9 deletions(-)
create mode 100644 tests/qemuxml2argvdata/graphics-dbus-chardev.args
create mode 100644 tests/qemuxml2argvdata/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 e249781ce027..1fbbcb33d0ca 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:
@@ -11408,6 +11426,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");
@@ -25262,6 +25284,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 cc81dbd4a9db..f70aaa2c1d65 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 80401cf8c737..176b7f675933 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 377e7e6f7623..c369e55969c2 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5290,6 +5290,15 @@ qemuBuildChrChardevStr(virLogManager *logManager,
dev->data.spiceport.channel);
break;
+ case VIR_DOMAIN_CHR_TYPE_DBUS:
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DISPLAY_DBUS)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("D-Bus chardev is not supported"));
+ }
+ virBufferAsprintf(&buf, "dbus,id=%s,name=%s", charAlias,
+ dev->data.dbus.channel);
+ break;
+
default:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported chardev '%s'"),
@@ -8754,6 +8763,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 9186d59ca2e5..b9c8e3472ce9 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6715,6 +6715,7 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
case VIR_DOMAIN_CHR_TYPE_PIPE:
case VIR_DOMAIN_CHR_TYPE_STDIO:
case VIR_DOMAIN_CHR_TYPE_NMDM:
+ case VIR_DOMAIN_CHR_TYPE_DBUS:
case VIR_DOMAIN_CHR_TYPE_LAST:
if (virDomainChrTypeToString(chr->type)) {
virReportError(VIR_ERR_OPERATION_FAILED,
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 56949775a3e6..64fa0d5dd00b 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -1953,6 +1953,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 1733d63410b3..649d86049b61 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.args
b/tests/qemuxml2argvdata/graphics-dbus-chardev.args
new file mode 100644
index 000000000000..c2b3718d8315
--- /dev/null
+++ b/tests/qemuxml2argvdata/graphics-dbus-chardev.args
@@ -0,0 +1,33 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+/usr/bin/qemu-system-i386 \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes
\
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-realtime mlock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-no-user-config \
+-nodefaults \
+-chardev
socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server=on,wait=off
\
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot strict=on \
+-usb \
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
+-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
+-chardev dbus,id=charserial0,name=org.qemu.console.serial.0 \
+-device isa-serial,chardev=charserial0,id=serial0 \
+-display dbus,p2p=on \
+-device cirrus-vga,id=video0,bus=pci.0,addr=0x2 \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/graphics-dbus-chardev.xml
b/tests/qemuxml2argvdata/graphics-dbus-chardev.xml
new file mode 100644
index 000000000000..69925d4d0611
--- /dev/null
+++ b/tests/qemuxml2argvdata/graphics-dbus-chardev.xml
@@ -0,0 +1,38 @@
+<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>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0'
target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <graphics type='dbus' p2p='yes'/>
+ <serial type="dbus">
+ <source channel="org.qemu.console.serial.0"/>
+ <target port="1"/>
+ </serial>
+ <video>
+ <model type='cirrus' vram='16384' heads='1'/>
+ </video>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index e1f032fe8a79..828c0ed77cfe 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1530,6 +1530,10 @@ mymain(void)
QEMU_CAPS_DEVICE_CIRRUS_VGA,
QEMU_CAPS_DISPLAY_DBUS,
QEMU_CAPS_CHARDEV_VDAGENT);
+ DO_TEST("graphics-dbus-chardev",
+ QEMU_CAPS_DEVICE_ISA_SERIAL,
+ QEMU_CAPS_DEVICE_CIRRUS_VGA,
+ QEMU_CAPS_DISPLAY_DBUS);
DO_TEST_NOCAPS("input-usbmouse");
DO_TEST_NOCAPS("input-usbtablet");
--
2.33.0.721.g106298f7f9