From nobody Mon Feb 9 23:01:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605690124; cv=none; d=zohomail.com; s=zohoarc; b=feESY2trO6eia4V8adfRffnFqIFT9GdDtcUlT+SYXtDqTquhSwi0rOtJeg7bSA0inUBvro8/EP+Xa7/5sSyNQnD6IPWBGUZkjwssbdL9/CA3illYZLuUHiLQ0IRbHjRJVkQsIeRuwg8aYIJcziCtIcDMlV3J0GOZQ+nTU0Kkpwo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605690124; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LwfAnqKkvd3KtGEnOzJlbeEpwQWJWYlc8So1esTOmIU=; b=H7d3rsvv0SQYDMQ4xXXIPijWx7B3CcG3CsafCgyC/fEg/vD7tPT9jmEeduXP5OL9PD0tARjam/RQ2NPBwuxWXopnLAWxxcYP0cd8kFjUFOsFgTuqxSG2flBfiy4HLvWxeN3h2h6A9ZXOKW3ZOzDbU3DfC9UPNMDHinF3XMrUF3c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1605690124719942.1464291306623; Wed, 18 Nov 2020 01:02:04 -0800 (PST) Received: from localhost ([::1]:52886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kfJLn-0001vs-Jf for importer@patchew.org; Wed, 18 Nov 2020 04:02:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52478) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kfIz5-0003SG-Av for qemu-devel@nongnu.org; Wed, 18 Nov 2020 03:38:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:38739) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kfIz3-0005gI-GD for qemu-devel@nongnu.org; Wed, 18 Nov 2020 03:38:35 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-118-7PIyPJDRNSCqua0o-ndpSg-1; Wed, 18 Nov 2020 03:38:30 -0500 Received: by mail-wr1-f69.google.com with SMTP id w6so637175wrk.1 for ; Wed, 18 Nov 2020 00:38:30 -0800 (PST) Received: from localhost (trasno.trasno.org. [83.165.45.250]) by smtp.gmail.com with ESMTPSA id a18sm2370036wmm.22.2020.11.18.00.38.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2020 00:38:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605688712; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LwfAnqKkvd3KtGEnOzJlbeEpwQWJWYlc8So1esTOmIU=; b=G+v4f6Njjb7VMoM9nJl9uAe9pMO2yE2+OkYz3wwNCRxxbA6EtPsmaFde+kGWvfDwD2bOFI 5RYVzTaqzmnltzMIBaAXL81DOLF3RbXeGXfOiCU5NGdPuwOV0/kDznvk3b4ltdGkqd39zc XXvf9/EVjPl82a9SfckPUvIx3f7/mfA= X-MC-Unique: 7PIyPJDRNSCqua0o-ndpSg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LwfAnqKkvd3KtGEnOzJlbeEpwQWJWYlc8So1esTOmIU=; b=m92nyRuFs8CVmq7BpztHmCe2PFVXwxxeyuxPNyMQQXvDiu/wOiVrYWk8HoACS/DJYx AF3Vcfvuoaqub2UfS5DfT/8CvvVObEccOiujuyV0VIeh+h5xXGpo3U4oxO9e2vlCsLaJ WjL/W1MJ+sp94uwzw4yzaPYupo/JCUbsO7pvZYTSu1YIKg0DO9NwrUx2A+/p9I1YRi1M eiwmGxBLYFO4cpaAMREGBNSQkVe7Imaaq/FMtNKeF0dHvtGT4UnjX3WQ/VwHBr9axyoM txVD5tR1lyqEFzFBgpng+cnC7PZJyWHvMY6GspVDqDlUxm2WNaZld8G6BC6WGZIQB1bA L9iw== X-Gm-Message-State: AOAM531SUnd1qD2ZLn7R1/KQjr2Y1SmZEkRl+1O49jyRoGcOfvyG1ghK boleWabJrPL08M7uopC43oaj1hTeT0M9t7HkaS1bZjMHwxYnBtgYMilieGBQiOt3JuSxNsKzydw 7W/t6WsT9AtcTKOTiPC0DZwqdrGuTxDwLGmNL8lGjSvsa7Yq8VR0OuPgYd7zRkUiNTx8= X-Received: by 2002:a5d:474f:: with SMTP id o15mr3446598wrs.377.1605688708650; Wed, 18 Nov 2020 00:38:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwyeIN2kKUcv+1zuXp4DBBqHeafXzwDENXn0I/nb1RV+Ft3m8XreFi5GW33TYmL1UD8m7XF3A== X-Received: by 2002:a5d:474f:: with SMTP id o15mr3446579wrs.377.1605688708418; Wed, 18 Nov 2020 00:38:28 -0800 (PST) From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PATCH v2 25/27] failover: Caller of this two functions already have primary_dev Date: Wed, 18 Nov 2020 09:37:46 +0100 Message-Id: <20201118083748.1328-26-quintela@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201118083748.1328-1-quintela@redhat.com> References: <20201118083748.1328-1-quintela@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=quintela@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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: pass client-ip=63.128.21.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/17 19:41:43 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Jason Wang , Juan Quintela , "Dr. David Alan Gilbert" , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Pass it as an argument. Signed-off-by: Juan Quintela --- hw/net/virtio-net.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 746ed3fb71..b37e9cd1d9 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3093,17 +3093,17 @@ void virtio_net_set_netclient_name(VirtIONet *n, co= nst char *name, n->netclient_type =3D g_strdup(type); } =20 -static bool failover_unplug_primary(VirtIONet *n) +static bool failover_unplug_primary(VirtIONet *n, DeviceState *dev) { HotplugHandler *hotplug_ctrl; PCIDevice *pci_dev; Error *err =3D NULL; =20 - hotplug_ctrl =3D qdev_get_hotplug_handler(n->primary_dev); + hotplug_ctrl =3D qdev_get_hotplug_handler(dev); if (hotplug_ctrl) { - pci_dev =3D PCI_DEVICE(n->primary_dev); + pci_dev =3D PCI_DEVICE(dev); pci_dev->partially_hotplugged =3D true; - hotplug_handler_unplug_request(hotplug_ctrl, n->primary_dev, &err); + hotplug_handler_unplug_request(hotplug_ctrl, dev, &err); if (err) { error_report_err(err); return false; @@ -3114,30 +3114,31 @@ static bool failover_unplug_primary(VirtIONet *n) return true; } =20 -static bool failover_replug_primary(VirtIONet *n, Error **errp) +static bool failover_replug_primary(VirtIONet *n, DeviceState *dev, + Error **errp) { Error *err =3D NULL; HotplugHandler *hotplug_ctrl; - PCIDevice *pdev =3D PCI_DEVICE(n->primary_dev); + PCIDevice *pdev =3D PCI_DEVICE(dev); BusState *primary_bus; =20 if (!pdev->partially_hotplugged) { return true; } - primary_bus =3D n->primary_dev->parent_bus; + primary_bus =3D dev->parent_bus; if (!primary_bus) { error_setg(errp, "virtio_net: couldn't find primary bus"); return false; } - qdev_set_parent_bus(n->primary_dev, primary_bus, &error_abort); + qdev_set_parent_bus(dev, primary_bus, &error_abort); qatomic_set(&n->failover_primary_hidden, false); - hotplug_ctrl =3D qdev_get_hotplug_handler(n->primary_dev); + hotplug_ctrl =3D qdev_get_hotplug_handler(dev); if (hotplug_ctrl) { - hotplug_handler_pre_plug(hotplug_ctrl, n->primary_dev, &err); + hotplug_handler_pre_plug(hotplug_ctrl, dev, &err); if (err) { goto out; } - hotplug_handler_plug(hotplug_ctrl, n->primary_dev, &err); + hotplug_handler_plug(hotplug_ctrl, dev, &err); } =20 out: @@ -3161,7 +3162,7 @@ static void virtio_net_handle_migration_primary(VirtI= ONet *n, } =20 if (migration_in_setup(s) && !should_be_hidden) { - if (failover_unplug_primary(n)) { + if (failover_unplug_primary(n, n->primary_dev)) { vmstate_unregister(VMSTATE_IF(n->primary_dev), qdev_get_vmsd(n->primary_dev), n->primary_dev); @@ -3172,7 +3173,7 @@ static void virtio_net_handle_migration_primary(VirtI= ONet *n, } } else if (migration_has_failed(s)) { /* We already unplugged the device let's plug it back */ - if (!failover_replug_primary(n, &err)) { + if (!failover_replug_primary(n, n->primary_dev, &err)) { if (err) { error_report_err(err); } --=20 2.26.2