]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: always generate the same alias for tls-creds-x509 object
authorPavel Hrdina <phrdina@redhat.com>
Tue, 18 Oct 2016 13:33:00 +0000 (15:33 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Tue, 18 Oct 2016 15:01:26 +0000 (17:01 +0200)
There was inconsistency between alias used to create tls-creds-x509
object and alias used to link that object to chardev while hotpluging.
Hotplug ends with this error:

  error: Failed to detach device from channel-tcp.xml
  error: internal error: unable to execute QEMU command 'chardev-add':
  No TLS credentials with id 'objcharchannel3_tls0'

In XML we have for example alias "serial0", but on qemu command line we
generate "charserial0".

The issue was that code, that creates QMP command to hotplug chardev
devices uses only the second alias "charserial0" and that alias is also
used to link the tls-creds-x509 object.

This patch unifies the aliases for tls-creds-x509 to be always generated
from "charserial0".

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
src/qemu/qemu_command.c
src/qemu/qemu_hotplug.c
tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-verify.args
tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev.args

index 848937c66a9cba6cc5f8f0c71c08e6f6a2e73285..828216250777b2ff31461f5587970a1207d1e0c5 100644 (file)
@@ -4949,10 +4949,10 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
             if (qemuBuildTLSx509CommandLine(cmd, cfg->chardevTLSx509certdir,
                                             dev->data.tcp.listen,
                                             cfg->chardevTLSx509verify,
-                                            alias, qemuCaps) < 0)
+                                            charAlias, qemuCaps) < 0)
                 goto error;
 
-            if (!(objalias = qemuAliasTLSObjFromChardevAlias(alias)))
+            if (!(objalias = qemuAliasTLSObjFromChardevAlias(charAlias)))
                 goto error;
             virBufferAsprintf(&buf, ",tls-creds=%s", objalias);
             VIR_FREE(objalias);
index af8758115456657e16064bfbc417c8ed2aeeaea2..2cb2267da38d5c9078b5258d0acc10650a67a9a2 100644 (file)
@@ -1738,7 +1738,7 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
                                          &tlsProps) < 0)
             goto cleanup;
 
-        if (!(tlsAlias = qemuAliasTLSObjFromChardevAlias(chr->info.alias)))
+        if (!(tlsAlias = qemuAliasTLSObjFromChardevAlias(charAlias)))
             goto cleanup;
         dev->data.tcp.tlscreds = true;
     }
@@ -4387,6 +4387,7 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver,
     virDomainChrDefPtr tmpChr;
     char *objAlias = NULL;
     char *devstr = NULL;
+    char *charAlias = NULL;
 
     if (!(tmpChr = virDomainChrFind(vmdef, chr))) {
         virReportError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -4399,9 +4400,12 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver,
 
     sa_assert(tmpChr->info.alias);
 
+    if (!(charAlias = qemuAliasChardevFromDevAlias(tmpChr->info.alias)))
+        goto cleanup;
+
     if (tmpChr->source.type == VIR_DOMAIN_CHR_TYPE_TCP &&
         cfg->chardevTLS &&
-        !(objAlias = qemuAliasTLSObjFromChardevAlias(tmpChr->info.alias)))
+        !(objAlias = qemuAliasTLSObjFromChardevAlias(charAlias)))
         goto cleanup;
 
     if (qemuBuildChrDeviceStr(&devstr, vmdef, chr, priv->qemuCaps) < 0)
@@ -4427,6 +4431,7 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver,
  cleanup:
     qemuDomainResetDeviceRemoval(vm);
     VIR_FREE(devstr);
+    VIR_FREE(charAlias);
     virObjectUnref(cfg);
     return ret;
 
index f521e334fcb3e9f03ad352f0847cbf29e695a243..003d11de72be24174014b41a786bf8ce66d47cc5 100644 (file)
@@ -25,9 +25,9 @@ server,nowait \
 -chardev udp,id=charserial0,host=127.0.0.1,port=2222,localaddr=127.0.0.1,\
 localport=1111 \
 -device isa-serial,chardev=charserial0,id=serial0 \
--object tls-creds-x509,id=objserial1_tls0,dir=/etc/pki/libvirt-chardev,\
+-object tls-creds-x509,id=objcharserial1_tls0,dir=/etc/pki/libvirt-chardev,\
 endpoint=client,verify-peer=yes \
 -chardev socket,id=charserial1,host=127.0.0.1,port=5555,\
-tls-creds=objserial1_tls0 \
+tls-creds=objcharserial1_tls0 \
 -device isa-serial,chardev=charserial1,id=serial1 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
index 4c8c23eb187c70cfead167be41a56fa88d5a7fc4..b456cce3041782258f74a78e5b5ec27e76652799 100644 (file)
@@ -25,9 +25,9 @@ server,nowait \
 -chardev udp,id=charserial0,host=127.0.0.1,port=2222,localaddr=127.0.0.1,\
 localport=1111 \
 -device isa-serial,chardev=charserial0,id=serial0 \
--object tls-creds-x509,id=objserial1_tls0,dir=/etc/pki/libvirt-chardev,\
+-object tls-creds-x509,id=objcharserial1_tls0,dir=/etc/pki/libvirt-chardev,\
 endpoint=client,verify-peer=no \
 -chardev socket,id=charserial1,host=127.0.0.1,port=5555,\
-tls-creds=objserial1_tls0 \
+tls-creds=objcharserial1_tls0 \
 -device isa-serial,chardev=charserial1,id=serial1 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3