From patchwork Mon Jun 26 18:01:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 106379 Delivered-To: patch@linaro.org Received: by 10.140.101.48 with SMTP id t45csp282867qge; Mon, 26 Jun 2017 11:09:44 -0700 (PDT) X-Received: by 10.237.35.174 with SMTP id j43mr1967485qtc.215.1498500584249; Mon, 26 Jun 2017 11:09:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498500584; cv=none; d=google.com; s=arc-20160816; b=WP5Kob2KreLd9gf8KDIeXNjqFjEUFlAVAUvkC93qHDEulTJ/FhP7RVwLz+hSOQ5xtE jvrgxt+R2F4X2EYoIA5Ax+bSuIfUCCz9OolZ9PcLl5gtMqS9meZ0R84GUgVILXOz9jIA RtRHZTIoYBi4yg6IOA8j7OYaCvaI9PdakcGmOBKMnp1xeRZOdB13gkYmZqBOhJxqsyzA aOFwVNxVy/ejbKVJ158biA0AMHdvX5Q/x3YcW+nkUiQ9LJoZi0yp4STJ5dZeQvxAzdRd iDAIbb7U6+dFWJIGK0DVacoKgNI5e+XCGCORfdqRm11UViJ75XpT0zuX0JDSbv+IyX0M OIaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:references :in-reply-to:message-id:date:to:from:delivered-to:dkim-filter :dmarc-filter:arc-authentication-results; bh=5jZo0NjIy/EOElrEL4pBd+lSwkP7fMknTfeK68X4zTc=; b=zck7myIa1+et1fFhm5mlQfqYnnMimnHMcpyzeF+YF2dRinfSqlaq+qMdg126pwI5BX txdAzHb9H1NiCnSwZVE5nSKvCz0T1jGdF0aotD8tLX7GfmSVH/P579JVSm6nPs1Gp202 LRswr0mZtGG53sEdZAO6KIbjEl8v+K1Nzx4AHaO1rg5k3fOyJdmOTH8NUNhCEDRbxsD1 oOSARaZdDyfOsq/QKznr49BMrQEqLDD9PM95h8O4RoFuxoQmNVQAUubDUi7tBfed3yR6 kdh0fQww8/vfkhsOronH/ZfxYgiLpr16WC7Qb2oEqfwH3bOcKxJOLHcPd0/9jo/oHu4z Sjnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id b25si641234qtc.47.2017.06.26.11.09.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Jun 2017 11:09:44 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 54A093DFCD; Mon, 26 Jun 2017 18:09:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 54A093DFCD Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 54A093DFCD Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 00203179E5; Mon, 26 Jun 2017 18:09:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8BD931853E33; Mon, 26 Jun 2017 18:09:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5QI3N0S008137 for ; Mon, 26 Jun 2017 14:03:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5C58B6BF6C; Mon, 26 Jun 2017 18:03:23 +0000 (UTC) Delivered-To: libvir-list@redhat.com Received: from worklaptop.redhat.com (ovpn-117-115.phx2.redhat.com [10.3.117.115]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CBC76BF6B; Mon, 26 Jun 2017 18:03:19 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 26 Jun 2017 14:01:52 -0400 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: cdall@linaro.org, drjones@redhat.com, riku.voipio@linaro.org, Andrea Bolognani Subject: [libvirt] [PATCH 11/12] qemu: command: support -chardev for platform devices X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 26 Jun 2017 18:09:43 +0000 (UTC) Some qemu arch/machine types have built in platform devices that are always implicitly available. For platform serial devices, the current code assumes that only old style -serial config can be used for these devices. Apparently though since -chardev was introduced, we can use -chardev in these cases, like this: -chardev pty,id=foo -serial chardev:foo Since -chardev enables all sorts of modern features, use this method for platform devices. Signed-off-by: Cole Robinson --- note: I only gave this light testing with a very new qemu, just made sure console output was still working. I'd appreciate if other folks can test it as well to make sure extra features like work as expected src/qemu/qemu_command.c | 125 ++------------------- src/qemu/qemu_process.c | 9 +- .../qemuxml2argv-aarch64-kvm-32-on-64.args | 3 +- ...l2argv-aarch64-virt-2.6-virtio-pci-default.args | 3 +- .../qemuxml2argv-aarch64-virt-virtio.args | 3 +- .../qemuxml2argv-aarch64-virtio-pci-default.args | 3 +- .../qemuxml2argv-arm-vexpressa9-basic.args | 3 +- .../qemuxml2argv-arm-vexpressa9-virtio.args | 3 +- .../qemuxml2argv-arm-virt-virtio.args | 3 +- tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args | 3 +- .../qemuxml2argv-ppce500-serial.args | 3 +- 11 files changed, 32 insertions(+), 129 deletions(-) -- 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Andrea Bolognani diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 056e62129..3e82ca086 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5514,106 +5514,6 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd, return 0; } -static char * -qemuBuildChrArgStr(const virDomainChrSourceDef *dev, - const char *prefix) -{ - virBuffer buf = VIR_BUFFER_INITIALIZER; - - if (dev->logfile) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("logfile not supported in this QEMU binary")); - goto error; - } - - if (prefix) - virBufferAdd(&buf, prefix, strlen(prefix)); - - switch ((virDomainChrType)dev->type) { - case VIR_DOMAIN_CHR_TYPE_NULL: - virBufferAddLit(&buf, "null"); - break; - - case VIR_DOMAIN_CHR_TYPE_VC: - virBufferAddLit(&buf, "vc"); - break; - - case VIR_DOMAIN_CHR_TYPE_PTY: - virBufferAddLit(&buf, "pty"); - break; - - case VIR_DOMAIN_CHR_TYPE_DEV: - virBufferStrcat(&buf, dev->data.file.path, NULL); - break; - - case VIR_DOMAIN_CHR_TYPE_FILE: - virBufferAsprintf(&buf, "file:%s", dev->data.file.path); - break; - - case VIR_DOMAIN_CHR_TYPE_PIPE: - virBufferAsprintf(&buf, "pipe:%s", dev->data.file.path); - break; - - case VIR_DOMAIN_CHR_TYPE_STDIO: - virBufferAddLit(&buf, "stdio"); - break; - - case VIR_DOMAIN_CHR_TYPE_UDP: { - const char *connectHost = dev->data.udp.connectHost; - const char *bindHost = dev->data.udp.bindHost; - const char *bindService = dev->data.udp.bindService; - - if (connectHost == NULL) - connectHost = ""; - if (bindHost == NULL) - bindHost = ""; - if (bindService == NULL) - bindService = "0"; - - virBufferAsprintf(&buf, "udp:%s:%s@%s:%s", - connectHost, - dev->data.udp.connectService, - bindHost, - bindService); - break; - } - case VIR_DOMAIN_CHR_TYPE_TCP: - if (dev->data.tcp.protocol == VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET) { - virBufferAsprintf(&buf, "telnet:%s:%s%s", - dev->data.tcp.host, - dev->data.tcp.service, - dev->data.tcp.listen ? ",server,nowait" : ""); - } else { - virBufferAsprintf(&buf, "tcp:%s:%s%s", - dev->data.tcp.host, - dev->data.tcp.service, - dev->data.tcp.listen ? ",server,nowait" : ""); - } - break; - - case VIR_DOMAIN_CHR_TYPE_UNIX: - virBufferAsprintf(&buf, "unix:%s%s", - dev->data.nix.path, - dev->data.nix.listen ? ",server,nowait" : ""); - break; - - case VIR_DOMAIN_CHR_TYPE_SPICEVMC: - case VIR_DOMAIN_CHR_TYPE_SPICEPORT: - case VIR_DOMAIN_CHR_TYPE_NMDM: - case VIR_DOMAIN_CHR_TYPE_LAST: - break; - } - - if (virBufferCheckError(&buf) < 0) - goto error; - - return virBufferContentAndReset(&buf); - - error: - virBufferFreeAndReset(&buf); - return NULL; -} - static int qemuBuildMonitorCommandLine(virLogManagerPtr logManager, @@ -9226,26 +9126,23 @@ qemuBuildSerialCommandLine(virLogManagerPtr logManager, if (serial->source->type == VIR_DOMAIN_CHR_TYPE_SPICEPORT && !havespice) continue; + if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, + serial->source, + serial->info.alias, + qemuCaps, true, + chardevStdioLogd))) + return -1; + virCommandAddArg(cmd, "-chardev"); + virCommandAddArg(cmd, devstr); + VIR_FREE(devstr); + /* Use -chardev with -device if they are available */ if (virQEMUCapsSupportsChardev(def, qemuCaps, serial)) { - if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, - serial->source, - serial->info.alias, - qemuCaps, true, - chardevStdioLogd))) - return -1; - virCommandAddArg(cmd, "-chardev"); - virCommandAddArg(cmd, devstr); - VIR_FREE(devstr); - if (qemuBuildChrDeviceCommandLine(cmd, def, serial, qemuCaps) < 0) return -1; } else { virCommandAddArg(cmd, "-serial"); - if (!(devstr = qemuBuildChrArgStr(serial->source, NULL))) - return -1; - virCommandAddArg(cmd, devstr); - VIR_FREE(devstr); + virCommandAddArgFormat(cmd, "chardev:char%s", serial->info.alias); } } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index d669dfb32..2341f0ab1 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1877,8 +1877,8 @@ qemuProcessMonitorReportLogError(qemuMonitorPtr mon ATTRIBUTE_UNUSED, static int -qemuProcessLookupPTYs(virDomainDefPtr def, - virQEMUCapsPtr qemuCaps, +qemuProcessLookupPTYs(virDomainDefPtr def ATTRIBUTE_UNUSED, + virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED, virDomainChrDefPtr *devices, int count, virHashTablePtr info) @@ -1887,14 +1887,11 @@ qemuProcessLookupPTYs(virDomainDefPtr def, for (i = 0; i < count; i++) { virDomainChrDefPtr chr = devices[i]; - bool chardevfmt = virQEMUCapsSupportsChardev(def, qemuCaps, chr); - if (chr->source->type == VIR_DOMAIN_CHR_TYPE_PTY) { char id[32]; qemuMonitorChardevInfoPtr entry; - if (snprintf(id, sizeof(id), "%s%s", - chardevfmt ? "char" : "", + if (snprintf(id, sizeof(id), "char%s", chr->info.alias) >= sizeof(id)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to format device alias " diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-kvm-32-on-64.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-kvm-32-on-64.args index 3af4564ad..693b48931 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-kvm-32-on-64.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-kvm-32-on-64.args @@ -26,4 +26,5 @@ server,nowait \ -device virtio-blk-device,drive=drive-virtio-disk0,id=virtio-disk0 \ -device virtio-net-device,vlan=0,id=net0,mac=52:54:00:09:a4:37 \ -net user,vlan=0,name=hostnet0 \ --serial pty +-chardev pty,id=charserial0 \ +-serial chardev:charserial0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-2.6-virtio-pci-default.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-2.6-virtio-pci-default.args index c640edc6f..662259e22 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-2.6-virtio-pci-default.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-2.6-virtio-pci-default.args @@ -33,7 +33,8 @@ path=/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \ id=virtio-disk0 \ -device virtio-net-pci,vlan=0,id=net0,mac=52:54:00:09:a4:37,bus=pci.2,addr=0x1 \ -net user,vlan=0,name=hostnet0 \ --serial pty \ +-chardev pty,id=charserial0 \ +-serial chardev:charserial0 \ -chardev pty,id=charconsole1 \ -device virtconsole,chardev=charconsole1,id=console1 \ -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x4 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args index eca4c4bac..b1f7e6ea5 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args @@ -29,7 +29,8 @@ path=/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \ -device virtio-blk-device,drive=drive-virtio-disk0,id=virtio-disk0 \ -device virtio-net-device,vlan=0,id=net0,mac=52:54:00:09:a4:37 \ -net user,vlan=0,name=hostnet0 \ --serial pty \ +-chardev pty,id=charserial0 \ +-serial chardev:charserial0 \ -chardev pty,id=charconsole1 \ -device virtconsole,chardev=charconsole1,id=console1 \ -device virtio-balloon-device,id=balloon0 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-default.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-default.args index a5bc66ecd..28ec390a1 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-default.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virtio-pci-default.args @@ -37,7 +37,8 @@ addr=0x1 \ id=virtio-disk0 \ -device virtio-net-pci,vlan=0,id=net0,mac=52:54:00:09:a4:37,bus=pci.1,addr=0x0 \ -net user,vlan=0,name=hostnet0 \ --serial pty \ +-chardev pty,id=charserial0 \ +-serial chardev:charserial0 \ -chardev pty,id=charconsole1 \ -device virtconsole,chardev=charconsole1,id=console1 \ -device virtio-balloon-pci,id=balloon0,bus=pci.4,addr=0x0 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-arm-vexpressa9-basic.args b/tests/qemuxml2argvdata/qemuxml2argv-arm-vexpressa9-basic.args index 198e663d6..73d1314b5 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-arm-vexpressa9-basic.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-arm-vexpressa9-basic.args @@ -27,4 +27,5 @@ server,nowait \ -drive file=/arm.raw,format=raw,if=sd,index=0 \ -net nic,macaddr=52:54:00:09:a4:37,vlan=0,model=lan9118,name=net0 \ -net user,vlan=0,name=hostnet0 \ --serial pty +-chardev pty,id=charserial0 \ +-serial chardev:charserial0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-arm-vexpressa9-virtio.args b/tests/qemuxml2argvdata/qemuxml2argv-arm-vexpressa9-virtio.args index 1402fead1..850775177 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-arm-vexpressa9-virtio.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-arm-vexpressa9-virtio.args @@ -29,7 +29,8 @@ server,nowait \ -device virtio-blk-device,drive=drive-virtio-disk0,id=virtio-disk0 \ -device virtio-net-device,vlan=0,id=net0,mac=52:54:00:09:a4:37 \ -net user,vlan=0,name=hostnet0 \ --serial pty \ +-chardev pty,id=charserial0 \ +-serial chardev:charserial0 \ -chardev pty,id=charconsole1 \ -device virtconsole,chardev=charconsole1,id=console1 \ -device virtio-balloon-device,id=balloon0 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-arm-virt-virtio.args b/tests/qemuxml2argvdata/qemuxml2argv-arm-virt-virtio.args index d391a4d02..f051839dd 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-arm-virt-virtio.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-arm-virt-virtio.args @@ -27,7 +27,8 @@ server,nowait \ -device virtio-blk-device,drive=drive-virtio-disk0,id=virtio-disk0 \ -device virtio-net-device,vlan=0,id=net0,mac=52:54:00:09:a4:37 \ -net user,vlan=0,name=hostnet0 \ --serial pty \ +-chardev pty,id=charserial0 \ +-serial chardev:charserial0 \ -chardev pty,id=charconsole1 \ -device virtconsole,chardev=charconsole1,id=console1 \ -device virtio-balloon-device,id=balloon0 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args b/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args index 182744c23..2cdb45e35 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args @@ -22,5 +22,6 @@ server,nowait \ -append 'root=/dev/ram rw console=ttyS0,115200' \ -dtb /media/ram/test.dtb \ -usb \ --serial pty \ +-chardev pty,id=charserial0 \ +-serial chardev:charserial0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-ppce500-serial.args b/tests/qemuxml2argvdata/qemuxml2argv-ppce500-serial.args index 87f4ee5e4..56b0a1c49 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-ppce500-serial.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-ppce500-serial.args @@ -21,5 +21,6 @@ server,nowait \ -initrd /media/ram/ramdisk \ -append 'root=/dev/ram rw console=ttyS0,115200' \ -usb \ --serial pty \ +-chardev pty,id=charserial0 \ +-serial chardev:charserial0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2