From patchwork Wed Jan 23 21:32:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 156418 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1202255jaa; Wed, 23 Jan 2019 13:34:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN6hSIIz7JZ+bDkoFEiDSYn4L0YTj9SwQSPsicT0ZYw4Fi9s0VTxzoJyhe6V8jjOlqetsL8Y X-Received: by 2002:a0c:a402:: with SMTP id w2mr3585924qvw.129.1548279260909; Wed, 23 Jan 2019 13:34:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548279260; cv=none; d=google.com; s=arc-20160816; b=uUiGqgx+Skuz0WtTWrAwBltkv08mg8O+6hU+ZTBGJUFwPc7xXDgtWTw+S9Tya/zdb/ khomuzQ286VdOg5f+KNCDEg3e+jLTHa3hjhUPUR8YEZYwNU0i5Pd++PX6JWhHpJ21o8u Wc4AVuuYHIjL5TfG+a05hyznwMouHTCenlzT86FuC7ClJIVKD3oJwqAjbyQ/80cVgEnm bAy6kZAHQzc9fzBygwzUxU0n8hvZzHGeMG/oNd20u6LlmjCIdkqC+06NBry5MuJlLGCP l/YQEgdb3+z1vNhmu/eKU2UCzZbTbmjga86tkLKieKLr7OvP38X+2WHfTAWOFI3qGMc+ ZYqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=q9EMnTvLLQHlha0Yg1/sjY4aqqfQfFb2cYNEvxGqQT4=; b=fj9BFSjvwXH/VbJBbGtGM2ybgLa4CRZqBbRV9Fde9M9I+8RbHZgUzb3Tbj8zufIoHK I9WKu8vvsUvu/qq6NPl/SaKgpbKEKls2VpRwEvgPl/tOLOLh4u48s5+719WIJZCWzV16 F9wczExti9OyAwSoCpE5LOTIANeRC1CZ7dNbcZGC2MGzESuY/e1M77slTHAUQC93/GTY MNX+PXLouKkrgx3VXUKrIeF6a1iifPLVxTL+CDBqnROUY89ZQpBuHLIfVftyvBPR0jgU WMUvOQ6q7Zo3JMUqZuJiyujgJTicQmoD3AqHWUnvMfJ4II41u6qB4ZsEIrdlxQH0WkKC HdtQ== 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 m58si8945388qtb.280.2019.01.23.13.34.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jan 2019 13:34:20 -0800 (PST) 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-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 37AC0432CB; Wed, 23 Jan 2019 21:34:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 036B860C6E; Wed, 23 Jan 2019 21:34:19 +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 A50D73F60D; Wed, 23 Jan 2019 21:34:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0NLYBHT032635 for ; Wed, 23 Jan 2019 16:34:12 -0500 Received: by smtp.corp.redhat.com (Postfix) id F0C64BA9E; Wed, 23 Jan 2019 21:34:11 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.redhat.com (ovpn-120-34.rdu2.redhat.com [10.10.120.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7A22BAA5; Wed, 23 Jan 2019 21:34:09 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Wed, 23 Jan 2019 16:32:48 -0500 Message-Id: <3da81528d9b14d709e1255b82b02d87b6f4bc6bd.1548278586.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 20/25] qemu: Support vsock model=virtio-{non-}transitional 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 23 Jan 2019 21:34:20 +0000 (UTC) Add model handling for virtio transitional devices. Ex: ... * "virtio-transitional" maps to qemu "vhost-vsock-pci-transitional" * "virtio-non-transitional" maps to qemu "vhost-vsock-pci-non-transitional" Signed-off-by: Cole Robinson --- docs/formatdomain.html.in | 4 +++- docs/schemas/domaincommon.rng | 6 +++++- src/conf/domain_conf.c | 5 ++++- src/conf/domain_conf.h | 2 ++ src/qemu/qemu_command.c | 9 +++++++-- src/qemu/qemu_domain_address.c | 13 ++++++++++++- .../virtio-non-transitional.x86_64-3.1.0.args | 3 +++ .../virtio-non-transitional.x86_64-latest.args | 3 +++ tests/qemuxml2argvdata/virtio-non-transitional.xml | 3 +++ .../virtio-transitional.x86_64-3.1.0.args | 1 + .../virtio-transitional.x86_64-latest.args | 2 ++ tests/qemuxml2argvdata/virtio-transitional.xml | 3 +++ .../qemuxml2xmloutdata/virtio-non-transitional.xml | 9 +++++++++ tests/qemuxml2xmloutdata/virtio-transitional.xml | 4 ++++ tests/qemuxml2xmltest.c | 6 ++++-- 15 files changed, 65 insertions(+), 8 deletions(-) -- 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Andrea Bolognani diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 05f2beb237..eed35ef545 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -8606,7 +8606,9 @@ qemu-kvm -net nic,model=? /dev/null

Vsock

A vsock host/guest interface. The model attribute - defaults to virtio. + defaults to virtio. Since 5.1.0 + model can also be 'virtio-transitional' and + 'virtio-non-transitional' The optional attribute address of the cid element specifies the CID assigned to the guest. If the attribute auto is set to yes, libvirt diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index ac7c558511..1e26d5efca 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4301,7 +4301,11 @@ - virtio + + virtio + virtio-transitional + virtio-non-transitional + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b51c2a86ee..55ee8da179 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -897,7 +897,10 @@ VIR_ENUM_IMPL(virDomainIOMMUModel, VIR_DOMAIN_IOMMU_MODEL_LAST, VIR_ENUM_IMPL(virDomainVsockModel, VIR_DOMAIN_VSOCK_MODEL_LAST, "default", - "virtio") + "virtio", + "virtio-transitional", + "virtio-non-transitional", +); VIR_ENUM_IMPL(virDomainDiskDiscard, VIR_DOMAIN_DISK_DISCARD_LAST, "default", diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index f79b3e5f48..f0d41e3153 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2420,6 +2420,8 @@ struct _virDomainIOMMUDef { typedef enum { VIR_DOMAIN_VSOCK_MODEL_DEFAULT, VIR_DOMAIN_VSOCK_MODEL_VIRTIO, + VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL, + VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL, VIR_DOMAIN_VSOCK_MODEL_LAST } virDomainVsockModel; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 614c9db291..9d64c7d7b0 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -509,6 +509,13 @@ qemuBuildVirtioDevStr(virBufferPtr buf, ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BALLOON_PCI_NON_TRANSITIONAL; break; + case VIR_DOMAIN_DEVICE_VSOCK: + has_tmodel = device.data.vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = device.data.vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL; + tmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_PCI_TRANSITIONAL; + ntmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_PCI_NON_TRANSITIONAL; + break; + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_INPUT: case VIR_DOMAIN_DEVICE_SOUND: @@ -527,7 +534,6 @@ qemuBuildVirtioDevStr(virBufferPtr buf, case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_MEMORY: case VIR_DOMAIN_DEVICE_IOMMU: - case VIR_DOMAIN_DEVICE_VSOCK: case VIR_DOMAIN_DEVICE_LAST: default: return 0; @@ -10494,7 +10500,6 @@ qemuBuildVsockDevStr(virDomainDefPtr def, virBuffer buf = VIR_BUFFER_INITIALIZER; char *ret = NULL; - if (qemuBuildVirtioDevStr(&buf, "vhost-vsock", qemuCaps, VIR_DOMAIN_DEVICE_VSOCK, vsock) < 0) { goto cleanup; diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 5164bcd49b..4767b7aadc 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -947,7 +947,18 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, break; case VIR_DOMAIN_DEVICE_VSOCK: - return virtioFlags; + switch ((virDomainVsockModel) dev->data.vsock->model) { + case VIR_DOMAIN_VSOCK_MODEL_VIRTIO: + case VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL: + return virtioFlags; + case VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL: + return pciFlags; + + case VIR_DOMAIN_VSOCK_MODEL_DEFAULT: + case VIR_DOMAIN_VSOCK_MODEL_LAST: + return 0; + } + break; /* These devices don't ever connect with PCI */ case VIR_DOMAIN_DEVICE_NVRAM: diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args index 30e8e4244e..97df54dd77 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args @@ -31,6 +31,7 @@ addr=0x1 \ -device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ -device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ -device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ +-device pcie-root-port,port=0xf,chassis=8,id=pci.8,bus=pcie.0,addr=0x1.0x7 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci,disable-legacy=on,disable-modern=off,scsi=off,bus=pci.3,\ addr=0x0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ @@ -49,4 +50,6 @@ bus=pci.5,addr=0x0 \ id=rng0,bus=pci.6,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ +-device vhost-vsock-pci,disable-legacy=on,disable-modern=off,id=vsock0,\ +guest-cid=4,vhostfd=6789,bus=pci.7,addr=0x0 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args index dbf7a4ef15..2a73798ee2 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args @@ -31,6 +31,7 @@ addr=0x1 \ -device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ -device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ -device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ +-device pcie-root-port,port=0xf,chassis=8,id=pci.8,bus=pcie.0,addr=0x1.0x7 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci-non-transitional,scsi=off,bus=pci.3,addr=0x0,\ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ @@ -47,4 +48,6 @@ id=hostdev0,bus=pci.4,addr=0x0 \ -device virtio-rng-pci-non-transitional,rng=objrng0,id=rng0,bus=pci.6,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ +-device vhost-vsock-pci-non-transitional,id=vsock0,guest-cid=4,vhostfd=6789,\ +bus=pci.7,addr=0x0 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.xml b/tests/qemuxml2argvdata/virtio-non-transitional.xml index b94ea58b5e..d4c07420dc 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml @@ -28,5 +28,8 @@ + + + diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args index c35e73ec45..d2429d2d2c 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args @@ -42,4 +42,5 @@ bus=pci.2,addr=0x4 \ -device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.2,addr=0x6 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ +-device vhost-vsock-pci,id=vsock0,guest-cid=4,vhostfd=6789,bus=pci.2,addr=0x7 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args index 77332549bf..f3a4e0804e 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args @@ -43,4 +43,6 @@ id=hostdev0,bus=pci.2,addr=0x4 \ -device virtio-rng-pci-transitional,rng=objrng0,id=rng0,bus=pci.2,addr=0x6 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ +-device vhost-vsock-pci-transitional,id=vsock0,guest-cid=4,vhostfd=6789,\ +bus=pci.2,addr=0x7 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.xml b/tests/qemuxml2argvdata/virtio-transitional.xml index 3bdb602a06..dd33071eb9 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-transitional.xml @@ -28,5 +28,8 @@ + + + diff --git a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml index 7490dfdbbf..5ba39ea30f 100644 --- a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml @@ -60,6 +60,11 @@

+ + + +
+ @@ -83,5 +88,9 @@ /dev/urandom
+ + +
+ diff --git a/tests/qemuxml2xmloutdata/virtio-transitional.xml b/tests/qemuxml2xmloutdata/virtio-transitional.xml index 2a42ce6359..5cb6568cc8 100644 --- a/tests/qemuxml2xmloutdata/virtio-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-transitional.xml @@ -62,5 +62,9 @@ /dev/urandom
+ + +
+ diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index a84f9241d6..c5ad3ba4b6 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1272,12 +1272,14 @@ mymain(void) QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE, QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, - QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY); + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, + QEMU_CAPS_DEVICE_VHOST_VSOCK); DO_TEST("virtio-non-transitional", QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE, QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, - QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY); + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, + QEMU_CAPS_DEVICE_VHOST_VSOCK); if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL) virFileDeleteTree(fakerootdir);