From nobody Wed Nov 27 04:52:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1701504098; cv=none; d=zohomail.com; s=zohoarc; b=Noy5KLnaZLY+UPKHFgrqzdMNjmLbNWtbLmwvgk6OfCqbv9HEwnSd1gMvXOQgt9gcJ894HbQ2paZhnyUsT0whiE/6SPr5AaopCcee3Wz5SODHsMdCcM0SYrmwc3SFICtuebYQGPiSoMio8psbzAk+ZkmtjTnESTxjMwngeM2/hsQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701504098; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aq8m7VGcssqI78XGOxjsweJbMFDzrgiYzBdT9vBPUfc=; b=A1ImfoTK1A21X6DnnwJ6YUObDFrVdBkTq2plkaVrQZ/8E1f5uLPZaMUsrysNPFLBvHYiMTQWbuCsepFsTNFk4vgSLVKvrR2RQ+iPj05uggUxZY4YjVDBAV/isHtu4BRavUGQeJ97B2/QaNoVX27/SBmAuYEIxNfpudAiHF6AYa4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701504098824234.06651173101886; Sat, 2 Dec 2023 00:01:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9Kw9-0004O7-4x; Sat, 02 Dec 2023 03:01:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r9Kvt-0004Lc-20 for qemu-devel@nongnu.org; Sat, 02 Dec 2023 03:01:02 -0500 Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9Kvp-00050W-8D for qemu-devel@nongnu.org; Sat, 02 Dec 2023 03:00:58 -0500 Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-6d7f3a4bbc6so970019a34.2 for ; Sat, 02 Dec 2023 00:00:56 -0800 (PST) Received: from localhost ([157.82.205.15]) by smtp.gmail.com with UTF8SMTPSA id w24-20020aa78598000000b006cdd1561dcbsm4087492pfn.134.2023.12.02.00.00.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 02 Dec 2023 00:00:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1701504055; x=1702108855; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=aq8m7VGcssqI78XGOxjsweJbMFDzrgiYzBdT9vBPUfc=; b=b9XJBbB2aCOw3MMvo6HE1iUlRJYx66nJw6BX2LWUb9ujDwznN2UPV1msIv0WhXU0IU LJq6Wt1IsOFVTYM8HFo6aO58Pxt0zUhHXOUuyJcJRCPyi+lC7veeqTJp9wRr8fUvpGTk acC0AdQU53KuL9WcLKC4G+RRx4Nk0h31InoKyjMt90+sNeAV8mMiRaCNm6GUC7+7V6vc 2vYQHrBxD5P5GPcO2AwBKHOpKn4v7ErvSJ8WAudyjVcwhMQh8DJ9GKqi6zPaggtLNhej lnXImSWy1uZDf6RA8vysbxbjMn0LBQg+pZUqJcKVcHRLWPlp2Z1YwVeGV0ZwHL+RPG4/ 8XFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701504055; x=1702108855; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aq8m7VGcssqI78XGOxjsweJbMFDzrgiYzBdT9vBPUfc=; b=MVC7H5A4EH1EIJPyQwRfZ1l4ZkJEPBIZ16KoNhcleUj/oc4dsDTIjDRKhcyIwGHGwP rulqjbASkQrtMU/ox4f4Oxg+ZxZsOEm2HaKqEEKu3sqki7ZDS8QiR9QmCyUis5udW/lM gZimizIAlBJCut/Ep+xBZ41IAkt6Du9BYOm1mXIhOiV5prbpnExaKf+BQMZI8j3ANrvc VPE8xVqsHR9A3T1Hcmt7CpQAtZAMLdh7jhzZadLmHWxSz25oEpNc6wl7Thn2to4qPXXG LgQFpifIFc27y+EWi3A/RIQTnLS2RP9hF4/5F3JG7JLCgDa+gwrRWipV7FlVfLKO8GUE xzIg== X-Gm-Message-State: AOJu0YyEIrUz9DtBAxBzJ6K1hir91dcYW95wbG22GhogDuCP8bB4hNZv m1fX2dibESzXuTwhb1Tpy3+W3A== X-Google-Smtp-Source: AGHT+IGP5DDkVd5YZHh+wEb+YwuRFEC5HDnv3mv3jAtKS7Ycukej4oyk+1C96W8a54tLTbhwEF0N5A== X-Received: by 2002:a54:458c:0:b0:3b8:b063:8275 with SMTP id z12-20020a54458c000000b003b8b0638275mr992499oib.119.1701504055569; Sat, 02 Dec 2023 00:00:55 -0800 (PST) From: Akihiko Odaki Date: Sat, 02 Dec 2023 17:00:28 +0900 Subject: [PATCH 05/14] virtio-net: Implement pci-failover MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20231202-sriov-v1-5-32b3570f7bd6@daynix.com> References: <20231202-sriov-v1-0-32b3570f7bd6@daynix.com> In-Reply-To: <20231202-sriov-v1-0-32b3570f7bd6@daynix.com> To: "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Jason Wang , Sriram Yagnaraman , Keith Busch , Klaus Jensen Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Yui Washizu , Akihiko Odaki X-Mailer: b4 0.12.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::32f; envelope-from=akihiko.odaki@daynix.com; helo=mail-ot1-x32f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1701504101132000002 This change removes the parsing of pci-device's failover_pair_id property from virtio-net, and lets pci-device to report an error if an unknown ID is specified for the property. Signed-off-by: Akihiko Odaki --- include/hw/virtio/virtio-net.h | 3 ++- hw/net/virtio-net.c | 24 ++++-------------------- hw/virtio/virtio-net-pci.c | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 55977f01f0..753cab4b32 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -218,7 +218,6 @@ struct VirtIONet { /* primary failover device is hidden*/ bool failover_primary_hidden; bool failover; - DeviceListener primary_listener; QDict *primary_opts; bool primary_opts_from_json; Notifier migration_state; @@ -233,6 +232,8 @@ size_t virtio_net_handle_ctrl_iov(VirtIODevice *vdev, unsigned out_num); void virtio_net_set_netclient_name(VirtIONet *n, const char *name, const char *type); +bool virtio_net_set_primary(VirtIONet *n, const QDict *device_opts, + bool from_json, Error **errp); uint64_t virtio_net_supported_guest_offloads(const VirtIONet *n); =20 #endif diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 80c56f0cfc..7def9a1200 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3536,19 +3536,11 @@ static void virtio_net_migration_state_notifier(Not= ifier *notifier, void *data) virtio_net_handle_migration_primary(n, s); } =20 -static bool failover_hide_primary_device(DeviceListener *listener, - const QDict *device_opts, - bool from_json, - Error **errp) +bool virtio_net_set_primary(VirtIONet *n, const QDict *device_opts, + bool from_json, Error **errp) { - VirtIONet *n =3D container_of(listener, VirtIONet, primary_listener); - const char *standby_id; - - if (!device_opts) { - return false; - } - - if (!qdict_haskey(device_opts, "failover_pair_id")) { + if (!n->failover) { + error_setg(errp, "failover pair does not support failover"); return false; } =20 @@ -3557,11 +3549,6 @@ static bool failover_hide_primary_device(DeviceListe= ner *listener, return false; } =20 - standby_id =3D qdict_get_str(device_opts, "failover_pair_id"); - if (g_strcmp0(standby_id, n->netclient_name) !=3D 0) { - return false; - } - /* * The hide helper can be called several times for a given device. * Check there is only one primary for a virtio-net device but @@ -3621,9 +3608,7 @@ static void virtio_net_device_realize(DeviceState *de= v, Error **errp) } =20 if (n->failover) { - n->primary_listener.hide_device =3D failover_hide_primary_device; qatomic_set(&n->failover_primary_hidden, true); - device_listener_register(&n->primary_listener); migration_add_notifier(&n->migration_state, virtio_net_migration_state_notifier); n->host_features |=3D (1ULL << VIRTIO_NET_F_STANDBY); @@ -3789,7 +3774,6 @@ static void virtio_net_device_unrealize(DeviceState *= dev) =20 if (n->failover) { qobject_unref(n->primary_opts); - device_listener_unregister(&n->primary_listener); migration_remove_notifier(&n->migration_state); } else { assert(n->primary_opts =3D=3D NULL); diff --git a/hw/virtio/virtio-net-pci.c b/hw/virtio/virtio-net-pci.c index e03543a70a..e421cd9cea 100644 --- a/hw/virtio/virtio-net-pci.c +++ b/hw/virtio/virtio-net-pci.c @@ -64,10 +64,19 @@ static void virtio_net_pci_realize(VirtIOPCIProxy *vpci= _dev, Error **errp) qdev_realize(vdev, BUS(&vpci_dev->bus), errp); } =20 +static bool virtio_net_pci_set_primary(DeviceState *dev, + const QDict *device_opts, + bool from_json, Error **errp) +{ + return virtio_net_set_primary(&VIRTIO_NET_PCI(dev)->vdev, device_opts, + from_json, errp); +} + static void virtio_net_pci_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); + PCIFailoverClass *pfc =3D PCI_FAILOVER_CLASS(klass); VirtioPCIClass *vpciklass =3D VIRTIO_PCI_CLASS(klass); =20 k->romfile =3D "efi-virtio.rom"; @@ -75,6 +84,7 @@ static void virtio_net_pci_class_init(ObjectClass *klass,= void *data) k->device_id =3D PCI_DEVICE_ID_VIRTIO_NET; k->revision =3D VIRTIO_PCI_ABI_VERSION; k->class_id =3D PCI_CLASS_NETWORK_ETHERNET; + pfc->set_primary =3D virtio_net_pci_set_primary; set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); device_class_set_props(dc, virtio_net_properties); vpciklass->realize =3D virtio_net_pci_realize; @@ -98,6 +108,10 @@ static const VirtioPCIDeviceTypeInfo virtio_net_pci_inf= o =3D { .instance_size =3D sizeof(VirtIONetPCI), .instance_init =3D virtio_net_pci_instance_init, .class_init =3D virtio_net_pci_class_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_PCI_FAILOVER }, + { } + }, }; =20 static void virtio_net_pci_register(void) --=20 2.43.0