This commit adds support for virtio-multitouch input devices. It
introduces the VIR_DOMAIN_INPUT_TYPE_MULTITOUCH type, adds the
QEMU multitouch capability, updates validation, updates command
building, and updates security labeling code to handle the new
device type.

Signed-off-by: Julio Faracco <[email protected]>
---
 src/conf/domain_audit.c         | 1 +
 src/conf/domain_conf.c          | 2 ++
 src/conf/domain_conf.h          | 1 +
 src/conf/domain_validate.c      | 9 +++++++++
 src/qemu/qemu_capabilities.c    | 3 +++
 src/qemu/qemu_capabilities.h    | 1 +
 src/qemu/qemu_command.c         | 5 +++++
 src/qemu/qemu_validate.c        | 5 +++++
 src/security/security_dac.c     | 2 ++
 src/security/security_selinux.c | 2 ++
 10 files changed, 31 insertions(+)

diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
index 7a6bb02203..ae7e2fac82 100644
--- a/src/conf/domain_audit.c
+++ b/src/conf/domain_audit.c
@@ -926,6 +926,7 @@ virDomainAuditInput(virDomainObj *vm,
 
     case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
     case VIR_DOMAIN_INPUT_TYPE_EVDEV:
+    case VIR_DOMAIN_INPUT_TYPE_MULTITOUCH:
         VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
                   "virt=%s resrc=evdev reason=%s %s uuid=%s path=%s",
                   virt, reason, vmname, uuidstr, 
VIR_AUDIT_STR(input->source.evdev));
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 9672168df9..88b4e055fd 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -916,6 +916,7 @@ VIR_ENUM_IMPL(virDomainInput,
               "keyboard",
               "passthrough",
               "evdev",
+              "multitouch",
 );
 
 VIR_ENUM_IMPL(virDomainInputBus,
@@ -2084,6 +2085,7 @@ const char *virDomainInputDefGetPath(virDomainInputDef 
*input)
 
     case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
     case VIR_DOMAIN_INPUT_TYPE_EVDEV:
+    case VIR_DOMAIN_INPUT_TYPE_MULTITOUCH:
         return input->source.evdev;
     }
     return NULL;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 83d49969d3..269649dd3c 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1554,6 +1554,7 @@ typedef enum {
     VIR_DOMAIN_INPUT_TYPE_KBD,
     VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH,
     VIR_DOMAIN_INPUT_TYPE_EVDEV,
+    VIR_DOMAIN_INPUT_TYPE_MULTITOUCH,
 
     VIR_DOMAIN_INPUT_TYPE_LAST
 } virDomainInputType;
diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index 4482203087..63e08567a6 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -2930,6 +2930,15 @@ virDomainInputDefValidate(const virDomainInputDef *input,
         }
         break;
 
+    case VIR_DOMAIN_INPUT_TYPE_MULTITOUCH:
+        if (input->bus != VIR_DOMAIN_INPUT_BUS_VIRTIO) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("only bus 'virtio' is supported for 'multitouch' 
input devices"));
+            return -1;
+        }
+        break;
+
+
     case VIR_DOMAIN_INPUT_TYPE_EVDEV:
         if (input->bus != VIR_DOMAIN_INPUT_BUS_NONE) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index f456e8a378..a5e19b8c01 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -755,6 +755,7 @@ VIR_ENUM_IMPL(virQEMUCaps,
               "disk-timed-stats", /* QEMU_CAPS_DISK_TIMED_STATS */
               "query-accelerators", /* QEMU_CAPS_QUERY_ACCELERATORS */
               "mshv", /* QEMU_CAPS_MSHV */
+              "virtio-multitouch", /* QEMU_CAPS_VIRTIO_MULTITOUCH */
     );
 
 
@@ -1349,6 +1350,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
     { "virtio-tablet-pci", QEMU_CAPS_VIRTIO_TABLET },
     { "virtio-input-host-device", QEMU_CAPS_VIRTIO_INPUT_HOST },
     { "virtio-input-host-pci", QEMU_CAPS_VIRTIO_INPUT_HOST },
+    { "virtio-multitouch-pci", QEMU_CAPS_VIRTIO_MULTITOUCH },
+    { "virtio-multitouch-device", QEMU_CAPS_VIRTIO_MULTITOUCH },
     { "mptsas1068", QEMU_CAPS_SCSI_MPTSAS1068 },
     { "pxb", QEMU_CAPS_DEVICE_PXB },
     { "pxb-pcie", QEMU_CAPS_DEVICE_PXB_PCIE },
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index f180844e66..44a3350cf9 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -730,6 +730,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for 
syntax-check */
     QEMU_CAPS_DISK_TIMED_STATS, /* timed stats support ('stats-intervals' 
property of disk frontends) */
     QEMU_CAPS_QUERY_ACCELERATORS, /* query-accelerators command */
     QEMU_CAPS_MSHV, /* -accel mshv */
+    QEMU_CAPS_VIRTIO_MULTITOUCH, /* -device virtio-multitouch-{device,pci} */
 
     QEMU_CAPS_LAST /* this must always be the last item */
 } virQEMUCapsFlags;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index e81efdfde7..369646a4c7 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -929,6 +929,10 @@ qemuBuildVirtioDevGetConfigDev(const virDomainDeviceDef 
*device,
                 *baseName = "virtio-input-host";
                 break;
 
+            case VIR_DOMAIN_INPUT_TYPE_MULTITOUCH:
+                *baseName = "virtio-multitouch";
+                break;
+
             case VIR_DOMAIN_INPUT_TYPE_EVDEV:
             case VIR_DOMAIN_INPUT_TYPE_LAST:
             default:
@@ -4304,6 +4308,7 @@ qemuBuildInputVirtioDevProps(const virDomainDef *def,
     switch ((virDomainInputType)dev->type) {
     case VIR_DOMAIN_INPUT_TYPE_MOUSE:
     case VIR_DOMAIN_INPUT_TYPE_TABLET:
+    case VIR_DOMAIN_INPUT_TYPE_MULTITOUCH:
     case VIR_DOMAIN_INPUT_TYPE_KBD:
     case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
         break;
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 184c23d307..44962fee92 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -5490,6 +5490,11 @@ qemuValidateDomainDeviceDefInput(const virDomainInputDef 
*input,
         cap = QEMU_CAPS_INPUT_LINUX;
         ccwCap = QEMU_CAPS_LAST;
         break;
+    case VIR_DOMAIN_INPUT_TYPE_MULTITOUCH:
+        baseName = "virtio-multitouch";
+        cap = QEMU_CAPS_VIRTIO_MULTITOUCH;
+        ccwCap = QEMU_CAPS_LAST;
+        break;
     case VIR_DOMAIN_INPUT_TYPE_LAST:
     default:
         virReportEnumRangeError(virDomainInputType,
diff --git a/src/security/security_dac.c b/src/security/security_dac.c
index 2f788b872a..85e6954018 100644
--- a/src/security/security_dac.c
+++ b/src/security/security_dac.c
@@ -1830,6 +1830,7 @@ virSecurityDACSetInputLabel(virSecurityManager *mgr,
     switch ((virDomainInputType)input->type) {
     case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
     case VIR_DOMAIN_INPUT_TYPE_EVDEV:
+    case VIR_DOMAIN_INPUT_TYPE_MULTITOUCH:
         if (virSecurityDACGetIds(seclabel, priv, &user, &group, NULL, NULL) < 
0)
             return -1;
 
@@ -1858,6 +1859,7 @@ virSecurityDACRestoreInputLabel(virSecurityManager *mgr,
 
     switch ((virDomainInputType)input->type) {
     case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
+    case VIR_DOMAIN_INPUT_TYPE_MULTITOUCH:
     case VIR_DOMAIN_INPUT_TYPE_EVDEV:
         ret = virSecurityDACRestoreFileLabel(mgr, input->source.evdev);
         break;
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index 2f3cc274a5..2d9aaa6e32 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -1597,6 +1597,7 @@ virSecuritySELinuxSetInputLabel(virSecurityManager *mgr,
     switch ((virDomainInputType)input->type) {
     case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
     case VIR_DOMAIN_INPUT_TYPE_EVDEV:
+    case VIR_DOMAIN_INPUT_TYPE_MULTITOUCH:
         if (virSecuritySELinuxSetFilecon(mgr, input->source.evdev,
                                          seclabel->imagelabel, true) < 0)
             return -1;
@@ -1626,6 +1627,7 @@ virSecuritySELinuxRestoreInputLabel(virSecurityManager 
*mgr,
 
     switch ((virDomainInputType)input->type) {
     case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
+    case VIR_DOMAIN_INPUT_TYPE_MULTITOUCH:
     case VIR_DOMAIN_INPUT_TYPE_EVDEV:
         return virSecuritySELinuxRestoreFileLabel(mgr, input->source.evdev, 
true, false);
 
-- 
2.52.0

Reply via email to