From nobody Mon May 6 20:57:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1545146984853102.3995017611204; Tue, 18 Dec 2018 07:29:44 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D2ECF9D4F8; Tue, 18 Dec 2018 14:32:30 +0000 (UTC) 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 CE4F24D722; Tue, 18 Dec 2018 14:32:29 +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 A1D25181B9E7; Tue, 18 Dec 2018 14:32:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wBIEWPnA010932 for ; Tue, 18 Dec 2018 09:32:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id A5EF8600C9; Tue, 18 Dec 2018 14:32:25 +0000 (UTC) Received: from thuth.com (dhcp-200-199.str.redhat.com [10.33.200.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id F3B60600CC; Tue, 18 Dec 2018 14:32:23 +0000 (UTC) From: Thomas Huth To: Markus Armbruster , qemu-devel@nongnu.org, Paolo Bonzini Date: Tue, 18 Dec 2018 15:32:19 +0100 Message-Id: <1545143539-26253-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com, Igor Mammedov , Eduardo Habkost , Marcel Apfelbaum , "Michael S. Tsirkin" Subject: [libvirt] [QEMU PATCH] hw/misc/ivshmem: Remove deprecated "ivshmem" legacy device 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 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 18 Dec 2018 14:32:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" It's been marked as deprecated in QEMU v2.6.0 already, so really nobody should use the legacy "ivshmem" device anymore (but use ivshmem-plain or ivshmem-doorbell instead). Time to remove the deprecated device now. Signed-off-by: Thomas Huth --- docs/specs/ivshmem-spec.txt | 8 +- hw/i386/pc_piix.c | 4 - hw/misc/ivshmem.c | 206 +---------------------------------------= ---- qemu-deprecated.texi | 5 -- scripts/device-crash-test | 1 - tests/ivshmem-test.c | 65 +++++--------- 6 files changed, 29 insertions(+), 260 deletions(-) diff --git a/docs/specs/ivshmem-spec.txt b/docs/specs/ivshmem-spec.txt index a1f5499..042f7ea 100644 --- a/docs/specs/ivshmem-spec.txt +++ b/docs/specs/ivshmem-spec.txt @@ -17,12 +17,16 @@ get interrupted by its peers. =20 There are two basic configurations: =20 -- Just shared memory: -device ivshmem-plain,memdev=3DHMB,... +- Just shared memory: + + -device ivshmem-plain,memdev=3DHMB,... =20 This uses host memory backend HMB. It should have option "share" set. =20 -- Shared memory plus interrupts: -device ivshmem,chardev=3DCHR,vectors=3DN= ,... +- Shared memory plus interrupts: + + -device ivshmem-doorbell,chardev=3DCHR,vectors=3DN,... =20 An ivshmem server must already be running on the host. The device connects to the server's UNIX domain socket via character device diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 7653fbb..5cbe976 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -725,10 +725,6 @@ DEFINE_I440FX_MACHINE(v1_3, "pc-1.3", pc_compat_1_3, .property =3D "msix",\ .value =3D "off",\ },{\ - .driver =3D "ivshmem",\ - .property =3D "use64",\ - .value =3D "0",\ - },{\ .driver =3D "qxl",\ .property =3D "revision",\ .value =3D stringify(3),\ diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index 8213659..2ab741f 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -112,13 +112,6 @@ typedef struct IVShmemState { /* migration stuff */ OnOffAuto master; Error *migration_blocker; - - /* legacy cruft */ - char *role; - char *shmobj; - char *sizearg; - size_t legacy_size; - uint32_t not_legacy_32bit; } IVShmemState; =20 /* registers for the Inter-VM shared memory device */ @@ -529,17 +522,6 @@ static void process_msg_shmem(IVShmemState *s, int fd,= Error **errp) =20 size =3D buf.st_size; =20 - /* Legacy cruft */ - if (s->legacy_size !=3D SIZE_MAX) { - if (size < s->legacy_size) { - error_setg(errp, "server sent only %zd bytes of shared memory", - (size_t)buf.st_size); - close(fd); - return; - } - size =3D s->legacy_size; - } - /* mmap the region and map into the BAR2 */ memory_region_init_ram_from_fd(&s->server_bar2, OBJECT(s), "ivshmem.bar2", size, true, fd, &local_= err); @@ -882,8 +864,8 @@ static void ivshmem_common_realize(PCIDevice *dev, Erro= r **errp) IVShmemState *s =3D IVSHMEM_COMMON(dev); Error *err =3D NULL; uint8_t *pci_conf; - uint8_t attr =3D PCI_BASE_ADDRESS_SPACE_MEMORY | - PCI_BASE_ADDRESS_MEM_PREFETCH; + const uint8_t attr =3D PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_PREFETCH | PCI_BASE_ADDRESS_MEM_TYPE_64; Error *local_err =3D NULL; =20 /* IRQFD requires MSI */ @@ -903,10 +885,6 @@ static void ivshmem_common_realize(PCIDevice *dev, Err= or **errp) pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->ivshmem_mmio); =20 - if (s->not_legacy_32bit) { - attr |=3D PCI_BASE_ADDRESS_MEM_TYPE_64; - } - if (s->hostmem !=3D NULL) { IVSHMEM_DPRINTF("using hostmem\n"); =20 @@ -1084,13 +1062,6 @@ static Property ivshmem_plain_properties[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 -static void ivshmem_plain_init(Object *obj) -{ - IVShmemState *s =3D IVSHMEM_PLAIN(obj); - - s->not_legacy_32bit =3D 1; -} - static void ivshmem_plain_realize(PCIDevice *dev, Error **errp) { IVShmemState *s =3D IVSHMEM_COMMON(dev); @@ -1122,7 +1093,6 @@ static const TypeInfo ivshmem_plain_info =3D { .name =3D TYPE_IVSHMEM_PLAIN, .parent =3D TYPE_IVSHMEM_COMMON, .instance_size =3D sizeof(IVShmemState), - .instance_init =3D ivshmem_plain_init, .class_init =3D ivshmem_plain_class_init, }; =20 @@ -1155,8 +1125,6 @@ static void ivshmem_doorbell_init(Object *obj) IVShmemState *s =3D IVSHMEM_DOORBELL(obj); =20 s->features |=3D (1 << IVSHMEM_MSI); - s->legacy_size =3D SIZE_MAX; /* whatever the server sends */ - s->not_legacy_32bit =3D 1; } =20 static void ivshmem_doorbell_realize(PCIDevice *dev, Error **errp) @@ -1189,181 +1157,11 @@ static const TypeInfo ivshmem_doorbell_info =3D { .class_init =3D ivshmem_doorbell_class_init, }; =20 -static int ivshmem_load_old(QEMUFile *f, void *opaque, int version_id) -{ - IVShmemState *s =3D opaque; - PCIDevice *pdev =3D PCI_DEVICE(s); - int ret; - - IVSHMEM_DPRINTF("ivshmem_load_old\n"); - - if (version_id !=3D 0) { - return -EINVAL; - } - - ret =3D ivshmem_pre_load(s); - if (ret) { - return ret; - } - - ret =3D pci_device_load(pdev, f); - if (ret) { - return ret; - } - - if (ivshmem_has_feature(s, IVSHMEM_MSI)) { - msix_load(pdev, f); - ivshmem_msix_vector_use(s); - } else { - s->intrstatus =3D qemu_get_be32(f); - s->intrmask =3D qemu_get_be32(f); - } - - return 0; -} - -static bool test_msix(void *opaque, int version_id) -{ - IVShmemState *s =3D opaque; - - return ivshmem_has_feature(s, IVSHMEM_MSI); -} - -static bool test_no_msix(void *opaque, int version_id) -{ - return !test_msix(opaque, version_id); -} - -static const VMStateDescription ivshmem_vmsd =3D { - .name =3D "ivshmem", - .version_id =3D 1, - .minimum_version_id =3D 1, - .pre_load =3D ivshmem_pre_load, - .post_load =3D ivshmem_post_load, - .fields =3D (VMStateField[]) { - VMSTATE_PCI_DEVICE(parent_obj, IVShmemState), - - VMSTATE_MSIX_TEST(parent_obj, IVShmemState, test_msix), - VMSTATE_UINT32_TEST(intrstatus, IVShmemState, test_no_msix), - VMSTATE_UINT32_TEST(intrmask, IVShmemState, test_no_msix), - - VMSTATE_END_OF_LIST() - }, - .load_state_old =3D ivshmem_load_old, - .minimum_version_id_old =3D 0 -}; - -static Property ivshmem_properties[] =3D { - DEFINE_PROP_CHR("chardev", IVShmemState, server_chr), - DEFINE_PROP_STRING("size", IVShmemState, sizearg), - DEFINE_PROP_UINT32("vectors", IVShmemState, vectors, 1), - DEFINE_PROP_BIT("ioeventfd", IVShmemState, features, IVSHMEM_IOEVENTFD, - false), - DEFINE_PROP_BIT("msi", IVShmemState, features, IVSHMEM_MSI, true), - DEFINE_PROP_STRING("shm", IVShmemState, shmobj), - DEFINE_PROP_STRING("role", IVShmemState, role), - DEFINE_PROP_UINT32("use64", IVShmemState, not_legacy_32bit, 1), - DEFINE_PROP_END_OF_LIST(), -}; - -static void desugar_shm(IVShmemState *s) -{ - Object *obj; - char *path; - - obj =3D object_new("memory-backend-file"); - path =3D g_strdup_printf("/dev/shm/%s", s->shmobj); - object_property_set_str(obj, path, "mem-path", &error_abort); - g_free(path); - object_property_set_int(obj, s->legacy_size, "size", &error_abort); - object_property_set_bool(obj, true, "share", &error_abort); - object_property_add_child(OBJECT(s), "internal-shm-backend", obj, - &error_abort); - object_unref(obj); - user_creatable_complete(USER_CREATABLE(obj), &error_abort); - s->hostmem =3D MEMORY_BACKEND(obj); -} - -static void ivshmem_realize(PCIDevice *dev, Error **errp) -{ - IVShmemState *s =3D IVSHMEM_COMMON(dev); - - if (!qtest_enabled()) { - warn_report("ivshmem is deprecated, please use ivshmem-plain" - " or ivshmem-doorbell instead"); - } - - if (qemu_chr_fe_backend_connected(&s->server_chr) + !!s->shmobj !=3D 1= ) { - error_setg(errp, "You must specify either 'shm' or 'chardev'"); - return; - } - - if (s->sizearg =3D=3D NULL) { - s->legacy_size =3D 4 * MiB; /* 4 MB default */ - } else { - int ret; - uint64_t size; - - ret =3D qemu_strtosz_MiB(s->sizearg, NULL, &size); - if (ret < 0 || (size_t)size !=3D size || !is_power_of_2(size)) { - error_setg(errp, "Invalid size %s", s->sizearg); - return; - } - s->legacy_size =3D size; - } - - /* check that role is reasonable */ - if (s->role) { - if (strncmp(s->role, "peer", 5) =3D=3D 0) { - s->master =3D ON_OFF_AUTO_OFF; - } else if (strncmp(s->role, "master", 7) =3D=3D 0) { - s->master =3D ON_OFF_AUTO_ON; - } else { - error_setg(errp, "'role' must be 'peer' or 'master'"); - return; - } - } else { - s->master =3D ON_OFF_AUTO_AUTO; - } - - if (s->shmobj) { - desugar_shm(s); - } - - /* - * Note: we don't use INTx with IVSHMEM_MSI at all, so this is a - * bald-faced lie then. But it's a backwards compatible lie. - */ - pci_config_set_interrupt_pin(dev->config, 1); - - ivshmem_common_realize(dev, errp); -} - -static void ivshmem_class_init(ObjectClass *klass, void *data) -{ - DeviceClass *dc =3D DEVICE_CLASS(klass); - PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); - - k->realize =3D ivshmem_realize; - k->revision =3D 0; - dc->desc =3D "Inter-VM shared memory (legacy)"; - dc->props =3D ivshmem_properties; - dc->vmsd =3D &ivshmem_vmsd; -} - -static const TypeInfo ivshmem_info =3D { - .name =3D TYPE_IVSHMEM, - .parent =3D TYPE_IVSHMEM_COMMON, - .instance_size =3D sizeof(IVShmemState), - .class_init =3D ivshmem_class_init, -}; - static void ivshmem_register_types(void) { type_register_static(&ivshmem_common_info); type_register_static(&ivshmem_plain_info); type_register_static(&ivshmem_doorbell_info); - type_register_static(&ivshmem_info); } =20 type_init(ivshmem_register_types) diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi index 190250f..038df3d 100644 --- a/qemu-deprecated.texi +++ b/qemu-deprecated.texi @@ -110,11 +110,6 @@ documentation of ``query-hotpluggable-cpus'' for addit= ional details. =20 @section System emulator devices =20 -@subsection ivshmem (since 2.6.0) - -The ``ivshmem'' device type is replaced by either the ``ivshmem-plain'' -or ``ivshmem-doorbell`` device types. - @subsection bluetooth (since 3.1) =20 The bluetooth subsystem is unmaintained since many years and likely bitrot= ten diff --git a/scripts/device-crash-test b/scripts/device-crash-test index e93a7c0..a835772 100755 --- a/scripts/device-crash-test +++ b/scripts/device-crash-test @@ -83,7 +83,6 @@ ERROR_WHITELIST =3D [ {'device':'isa-ipmi-bt', 'expected':True}, # IPMI device r= equires a bmc attribute to be set {'device':'isa-ipmi-kcs', 'expected':True}, # IPMI device r= equires a bmc attribute to be set {'device':'isa-parallel', 'expected':True}, # Can't create = serial device, empty char device - {'device':'ivshmem', 'expected':True}, # You must spec= ify either 'shm' or 'chardev' {'device':'ivshmem-doorbell', 'expected':True}, # You must spec= ify a 'chardev' {'device':'ivshmem-plain', 'expected':True}, # You must spec= ify a 'memdev' {'device':'loader', 'expected':True}, # please includ= e valid arguments diff --git a/tests/ivshmem-test.c b/tests/ivshmem-test.c index c37b196..9811d66 100644 --- a/tests/ivshmem-test.c +++ b/tests/ivshmem-test.c @@ -305,20 +305,18 @@ static void *server_thread(void *data) return NULL; } =20 -static void setup_vm_with_server(IVState *s, int nvectors, bool msi) +static void setup_vm_with_server(IVState *s, int nvectors) { - char *cmd =3D g_strdup_printf("-chardev socket,id=3Dchr0,path=3D%s,now= ait " - "-device ivshmem%s,chardev=3Dchr0,vectors= =3D%d", - tmpserver, - msi ? "-doorbell" : ",size=3D1M,msi=3Doff", - nvectors); + char *cmd =3D g_strdup_printf("-chardev socket,id=3Dchr0,path=3D%s,now= ait -device" + " ivshmem-doorbell,chardev=3Dchr0,vectors= =3D%d", + tmpserver, nvectors); =20 - setup_vm_cmd(s, cmd, msi); + setup_vm_cmd(s, cmd, true); =20 g_free(cmd); } =20 -static void test_ivshmem_server(bool msi) +static void test_ivshmem_server(void) { IVState state1, state2, *s1, *s2; ServerThread thread; @@ -341,9 +339,9 @@ static void test_ivshmem_server(bool msi) thread.thread =3D g_thread_new("ivshmem-server", server_thread, &threa= d); g_assert(thread.thread !=3D NULL); =20 - setup_vm_with_server(&state1, nvectors, msi); + setup_vm_with_server(&state1, nvectors); s1 =3D &state1; - setup_vm_with_server(&state2, nvectors, msi); + setup_vm_with_server(&state2, nvectors); s2 =3D &state2; =20 /* check got different VM ids */ @@ -355,39 +353,29 @@ static void test_ivshmem_server(bool msi) =20 /* check number of MSI-X vectors */ global_qtest =3D s1->qs->qts; - if (msi) { - ret =3D qpci_msix_table_size(s1->dev); - g_assert_cmpuint(ret, =3D=3D, nvectors); - } + ret =3D qpci_msix_table_size(s1->dev); + g_assert_cmpuint(ret, =3D=3D, nvectors); =20 /* TODO test behavior before MSI-X is enabled */ =20 /* ping vm2 -> vm1 on vector 0 */ - if (msi) { - ret =3D qpci_msix_pending(s1->dev, 0); - g_assert_cmpuint(ret, =3D=3D, 0); - } else { - g_assert_cmpuint(in_reg(s1, INTRSTATUS), =3D=3D, 0); - } + ret =3D qpci_msix_pending(s1->dev, 0); + g_assert_cmpuint(ret, =3D=3D, 0); out_reg(s2, DOORBELL, vm1 << 16); do { g_usleep(10000); - ret =3D msi ? qpci_msix_pending(s1->dev, 0) : in_reg(s1, INTRSTATU= S); + ret =3D qpci_msix_pending(s1->dev, 0); } while (ret =3D=3D 0 && g_get_monotonic_time() < end_time); g_assert_cmpuint(ret, !=3D, 0); =20 /* ping vm1 -> vm2 on vector 1 */ global_qtest =3D s2->qs->qts; - if (msi) { - ret =3D qpci_msix_pending(s2->dev, 1); - g_assert_cmpuint(ret, =3D=3D, 0); - } else { - g_assert_cmpuint(in_reg(s2, INTRSTATUS), =3D=3D, 0); - } + ret =3D qpci_msix_pending(s2->dev, 1); + g_assert_cmpuint(ret, =3D=3D, 0); out_reg(s1, DOORBELL, vm2 << 16 | 1); do { g_usleep(10000); - ret =3D msi ? qpci_msix_pending(s2->dev, 1) : in_reg(s2, INTRSTATU= S); + ret =3D qpci_msix_pending(s2->dev, 1); } while (ret =3D=3D 0 && g_get_monotonic_time() < end_time); g_assert_cmpuint(ret, !=3D, 0); =20 @@ -405,27 +393,17 @@ static void test_ivshmem_server(bool msi) close(thread.pipe[0]); } =20 -static void test_ivshmem_server_msi(void) -{ - test_ivshmem_server(true); -} - -static void test_ivshmem_server_irq(void) -{ - test_ivshmem_server(false); -} - #define PCI_SLOT_HP 0x06 =20 static void test_ivshmem_hotplug(void) { const char *arch =3D qtest_get_arch(); =20 - qtest_start(""); + qtest_start("-object memory-backend-ram,size=3D1M,id=3Dmb1"); =20 - qtest_qmp_device_add("ivshmem", - "iv1", "{'addr': %s, 'shm': %s, 'size': '1M'}", - stringify(PCI_SLOT_HP), tmpshm); + qtest_qmp_device_add("ivshmem-plain", "iv1", + "{'addr': %s, 'memdev': 'mb1'}", + stringify(PCI_SLOT_HP)); if (strcmp(arch, "ppc64") !=3D 0) { qpci_unplug_acpi_device_test("iv1", PCI_SLOT_HP); } @@ -525,8 +503,7 @@ int main(int argc, char **argv) if (g_test_slow()) { qtest_add_func("/ivshmem/pair", test_ivshmem_pair); if (strcmp(arch, "ppc64") !=3D 0) { - qtest_add_func("/ivshmem/server-msi", test_ivshmem_server_msi); - qtest_add_func("/ivshmem/server-irq", test_ivshmem_server_irq); + qtest_add_func("/ivshmem/server", test_ivshmem_server); } } =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list