[libvirt PATCH v3 13/16] conf: add <serial type='dbus'>

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>

Like a Spice port, a dbus serial must specify an associated channel name.

Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
---
 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                       |  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 +++++++++++++++++++
 tests/qemuxml2argvtest.c                      |  1 +
 .../graphics-dbus-chardev.xml                 |  1 +
 tests/qemuxml2xmltest.c                       |  3 ++
 13 files changed, 110 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 213e1a07c0e8..4d24ae6f878d 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4511,6 +4511,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 99cf63c1bc55..e62553eb039b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -710,6 +710,7 @@ VIR_ENUM_IMPL(virDomainChr,
               "spicevmc",
               "spiceport",
               "nmdm",
+              "dbus",
 );
 
 VIR_ENUM_IMPL(virDomainChrTcpProtocol,
@@ -2690,6 +2691,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;
     }
@@ -2733,6 +2735,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);
@@ -2787,7 +2793,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;
     }
 
@@ -2869,6 +2882,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:
@@ -11381,6 +11399,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");
@@ -25302,6 +25324,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 a94a9f5d816e..3562ad74462a 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1217,6 +1217,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;
@@ -1285,6 +1286,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 bde3266f2148..2e2fa45ea576 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1438,6 +1438,7 @@ qemuBuildChardevStr(const virDomainChrSourceDef *dev,
                           dev->data.spiceport.channel);
         break;
 
+    case VIR_DOMAIN_CHR_TYPE_DBUS:
     case VIR_DOMAIN_CHR_TYPE_NMDM:
     case VIR_DOMAIN_CHR_TYPE_LAST:
     default:
@@ -1542,6 +1543,7 @@ qemuBuildChardevCommand(virCommand *cmd,
     case VIR_DOMAIN_CHR_TYPE_UDP:
     case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
     case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
+    case VIR_DOMAIN_CHR_TYPE_DBUS:
         break;
 
     case VIR_DOMAIN_CHR_TYPE_NMDM:
@@ -8717,6 +8719,7 @@ qemuInterfaceVhostuserConnect(virCommand *cmd,
     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 e45b43eb5a31..b99381ecd2b1 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6819,6 +6819,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 0bfb17e09790..548287893a10 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -6886,6 +6886,7 @@ qemuProcessPrepareHostBackendChardevOne(virDomainDeviceDef *dev,
     case VIR_DOMAIN_CHR_TYPE_TCP:
     case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
     case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
+    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 7ab121aed0dc..8df3d7f19afa 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -1979,6 +1979,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/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 3510bcce6cff..22b819588115 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -411,6 +411,7 @@ testPrepareHostBackendChardevOne(virDomainDeviceDef *dev,
     case VIR_DOMAIN_CHR_TYPE_TCP:
     case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
     case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
+    case VIR_DOMAIN_CHR_TYPE_DBUS:
         break;
 
     case VIR_DOMAIN_CHR_TYPE_FILE:
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 4fcf5129c57e..eebb6d20cff0 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -390,6 +390,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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux