From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 15138677520741003.2436106960848; Thu, 21 Dec 2017 06:49:12 -0800 (PST) Received: from localhost ([::1]:53250 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS29R-0006t8-2L for importer@patchew.org; Thu, 21 Dec 2017 09:48:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1pM-0006n0-1z for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:28:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1pK-0004oo-HA for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:28:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51158) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1pK-0004oM-7E for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:28:02 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6DDE6C07F9AE; Thu, 21 Dec 2017 14:28:01 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with SMTP id 9200A189C7; Thu, 21 Dec 2017 14:27:58 +0000 (UTC) Date: Thu, 21 Dec 2017 16:27:58 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-2-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 21 Dec 2017 14:28:01 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 01/25] smbios: support setting OEM strings table X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" The cloud-init program currently allows fetching of its data by repurposing= of the 'system' type 'serial' field. This is a clear abuse of the serial field= that would clash with other valid usage a virt management app might have for that field. Fortunately the SMBIOS defines an "OEM Strings" table whose puporse is to a= llow exposing of arbitrary vendor specific strings to the operating system. This= is perfect for use with cloud-init, or as a way to pass arguments to OS instal= lers such as anaconda. This patch makes it easier to support this with QEMU. e.g. $QEMU -smbios type=3D11,value=3DHello,value=3DWorld,value=3DTricky,,value= =3Dtest Which results in the guest seeing dmidecode data Handle 0x0E00, DMI type 11, 5 bytes OEM Strings String 1: Hello String 2: World String 3: Tricky,value=3Dtest It is suggested that any app wanting to make use of this OEM strings capabi= lity for accepting data from the host mgmt layer should use its name as a string prefix. e.g. to expose OEM strings targetting both cloud init and anaconda = in parallel the mgmt app could set $QEMU -smbios type=3D11,value=3Dcloud-init:ds=3Dnocloud-net;s=3Dhttp://10= .10.0.1:8000/,\ value=3Danaconda:method=3Dhttp://dl.fedoraproject.org/pub/fedora/li= nux/releases/25/x86_64/os which would appear as Handle 0x0E00, DMI type 11, 5 bytes OEM Strings String 1: cloud-init:ds=3Dnocloud-net;s=3Dhttp://10.10.0.1:8000/ String 2: anaconda:method=3Dhttp://dl.fedoraproject.org/pub/fedor= a/linux/releases/25/x86_64/os Use of such string prefixes means the app won't have to care which string s= lot its data appears in. Signed-off-by: Daniel P. Berrange Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/smbios/smbios_build.h | 12 ++++++++ include/hw/smbios/smbios.h | 6 ++++ hw/smbios/smbios.c | 72 ++++++++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 90 insertions(+) diff --git a/hw/smbios/smbios_build.h b/hw/smbios/smbios_build.h index 68b8b72..93b360d 100644 --- a/hw/smbios/smbios_build.h +++ b/hw/smbios/smbios_build.h @@ -63,6 +63,18 @@ extern unsigned smbios_table_cnt; } \ } while (0) =20 +#define SMBIOS_TABLE_SET_STR_LIST(tbl_type, value) \ + do { \ + int len =3D (value !=3D NULL) ? strlen(value) + 1 : 0; = \ + if (len > 1) { \ + smbios_tables =3D g_realloc(smbios_tables, = \ + smbios_tables_len + len); \ + memcpy(smbios_tables + smbios_tables_len, value, len); \ + smbios_tables_len +=3D len; = \ + ++str_index; \ + } \ + } while (0) + #define SMBIOS_BUILD_TABLE_POST \ do { \ size_t term_cnt, t_size; \ diff --git a/include/hw/smbios/smbios.h b/include/hw/smbios/smbios.h index 31e8d5f..a83adb9 100644 --- a/include/hw/smbios/smbios.h +++ b/include/hw/smbios/smbios.h @@ -195,6 +195,12 @@ struct smbios_type_4 { uint16_t processor_family2; } QEMU_PACKED; =20 +/* SMBIOS type 11 - OEM strings */ +struct smbios_type_11 { + struct smbios_structure_header header; + uint8_t count; +} QEMU_PACKED; + /* SMBIOS type 16 - Physical Memory Array (v2.7) */ struct smbios_type_16 { struct smbios_structure_header header; diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 1a5437a..5d11f01 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -96,6 +96,11 @@ static struct { } type4; =20 static struct { + size_t nvalues; + const char **values; +} type11; + +static struct { const char *loc_pfx, *bank, *manufacturer, *serial, *asset, *part; uint16_t speed; } type17; @@ -282,6 +287,14 @@ static const QemuOptDesc qemu_smbios_type4_opts[] =3D { { /* end of list */ } }; =20 +static const QemuOptDesc qemu_smbios_type11_opts[] =3D { + { + .name =3D "value", + .type =3D QEMU_OPT_STRING, + .help =3D "OEM string data", + }, +}; + static const QemuOptDesc qemu_smbios_type17_opts[] =3D { { .name =3D "type", @@ -590,6 +603,27 @@ static void smbios_build_type_4_table(unsigned instanc= e) smbios_type4_count++; } =20 +static void smbios_build_type_11_table(void) +{ + char count_str[128]; + size_t i; + + if (type11.nvalues =3D=3D 0) { + return; + } + + SMBIOS_BUILD_TABLE_PRE(11, 0xe00, true); /* required */ + + snprintf(count_str, sizeof(count_str), "%zu", type11.nvalues); + t->count =3D type11.nvalues; + + for (i =3D 0; i < type11.nvalues; i++) { + SMBIOS_TABLE_SET_STR_LIST(11, type11.values[i]); + } + + SMBIOS_BUILD_TABLE_POST; +} + #define ONE_KB ((ram_addr_t)1 << 10) #define ONE_MB ((ram_addr_t)1 << 20) #define ONE_GB ((ram_addr_t)1 << 30) @@ -832,6 +866,8 @@ void smbios_get_tables(const struct smbios_phys_mem_are= a *mem_array, smbios_build_type_4_table(i); } =20 + smbios_build_type_11_table(); + #define MAX_DIMM_SZ (16ll * ONE_GB) #define GET_DIMM_SZ ((i < dimm_cnt - 1) ? MAX_DIMM_SZ \ : ((ram_size - 1) % MAX_DIMM_SZ) += 1) @@ -882,6 +918,38 @@ static void save_opt(const char **dest, QemuOpts *opts= , const char *name) } } =20 + +struct opt_list { + const char *name; + size_t *ndest; + const char ***dest; +}; + +static int save_opt_one(void *opaque, + const char *name, const char *value, + Error **errp) +{ + struct opt_list *opt =3D opaque; + + if (!g_str_equal(name, opt->name)) { + return 0; + } + + *opt->dest =3D g_renew(const char *, *opt->dest, (*opt->ndest) + 1); + (*opt->dest)[*opt->ndest] =3D value; + (*opt->ndest)++; + return 0; +} + +static void save_opt_list(size_t *ndest, const char ***dest, + QemuOpts *opts, const char *name) +{ + struct opt_list opt =3D { + name, ndest, dest, + }; + qemu_opt_foreach(opts, save_opt_one, &opt, NULL); +} + void smbios_entry_add(QemuOpts *opts, Error **errp) { const char *val; @@ -1035,6 +1103,10 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) save_opt(&type4.asset, opts, "asset"); save_opt(&type4.part, opts, "part"); return; + case 11: + qemu_opts_validate(opts, qemu_smbios_type11_opts, &error_fatal= ); + save_opt_list(&type11.nvalues, &type11.values, opts, "value"); + return; case 17: qemu_opts_validate(opts, qemu_smbios_type17_opts, &error_fatal= ); save_opt(&type17.loc_pfx, opts, "loc_pfx"); --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513868317837431.5664420488589; Thu, 21 Dec 2017 06:58:37 -0800 (PST) Received: from localhost ([::1]:53429 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS2In-0006k1-Lz for importer@patchew.org; Thu, 21 Dec 2017 09:58:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45200) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1pS-0006t0-Rg for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:28:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1pR-0004so-D2 for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:28:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47120) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1pR-0004sA-3T for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:28:09 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4E2BB369BD; Thu, 21 Dec 2017 14:28:08 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0350B381BC; Thu, 21 Dec 2017 14:28:01 +0000 (UTC) Date: Thu, 21 Dec 2017 16:28:01 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-3-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 21 Dec 2017 14:28:08 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 02/25] qdev-properties: add UUID property type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Juan Quintela , Markus Armbruster , Peter Xu , Roman Kagan , Paolo Bonzini , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Roman Kagan UUIDs (GUIDs) are widely used in VMBus-related stuff, so a dedicated property type becomes helpful. The property accepts a string-formatted UUID or a special keyword "auto" meaning a randomly generated UUID; the latter is also the default when the property is not given a value explicitly. Signed-off-by: Roman Kagan Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/qdev-properties.h | 9 +++++++ hw/core/qdev-properties.c | 61 ++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 70 insertions(+) diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index e2321f1..97e810e 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -30,6 +30,7 @@ extern const PropertyInfo qdev_prop_vlan; extern const PropertyInfo qdev_prop_pci_devfn; extern const PropertyInfo qdev_prop_blocksize; extern const PropertyInfo qdev_prop_pci_host_devaddr; +extern const PropertyInfo qdev_prop_uuid; extern const PropertyInfo qdev_prop_arraylen; extern const PropertyInfo qdev_prop_link; =20 @@ -213,6 +214,14 @@ extern const PropertyInfo qdev_prop_link; #define DEFINE_PROP_MEMORY_REGION(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_ptr, MemoryRegion *) =20 +#define DEFINE_PROP_UUID(_name, _state, _field) { \ + .name =3D (_name), \ + .info =3D &qdev_prop_uuid, \ + .offset =3D offsetof(_state, _field) \ + + type_check(QemuUUID, typeof_field(_state, _field)), \ + .set_default =3D true, \ + } + #define DEFINE_PROP_END_OF_LIST() \ {} =20 diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 1dc80fc..24c1780 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -10,6 +10,7 @@ #include "net/hub.h" #include "qapi/visitor.h" #include "chardev/char.h" +#include "qemu/uuid.h" =20 void qdev_prop_set_after_realize(DeviceState *dev, const char *name, Error **errp) @@ -883,6 +884,66 @@ const PropertyInfo qdev_prop_pci_host_devaddr =3D { .set =3D set_pci_host_devaddr, }; =20 +/* --- UUID --- */ + +static void get_uuid(Object *obj, Visitor *v, const char *name, void *opaq= ue, + Error **errp) +{ + DeviceState *dev =3D DEVICE(obj); + Property *prop =3D opaque; + QemuUUID *uuid =3D qdev_get_prop_ptr(dev, prop); + char buffer[UUID_FMT_LEN + 1]; + char *p =3D buffer; + + qemu_uuid_unparse(uuid, buffer); + + visit_type_str(v, name, &p, errp); +} + +#define UUID_VALUE_AUTO "auto" + +static void set_uuid(Object *obj, Visitor *v, const char *name, void *opaq= ue, + Error **errp) +{ + DeviceState *dev =3D DEVICE(obj); + Property *prop =3D opaque; + QemuUUID *uuid =3D qdev_get_prop_ptr(dev, prop); + Error *local_err =3D NULL; + char *str; + + if (dev->realized) { + qdev_prop_set_after_realize(dev, name, errp); + return; + } + + visit_type_str(v, name, &str, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + if (!strcmp(str, UUID_VALUE_AUTO)) { + qemu_uuid_generate(uuid); + } else if (qemu_uuid_parse(str, uuid) < 0) { + error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str); + } + g_free(str); +} + +static void set_default_uuid_auto(Object *obj, const Property *prop) +{ + object_property_set_str(obj, UUID_VALUE_AUTO, prop->name, &error_abort= ); +} + +const PropertyInfo qdev_prop_uuid =3D { + .name =3D "str", + .description =3D "UUID (aka GUID) or \"" UUID_VALUE_AUTO + "\" for random value (default)", + .get =3D get_uuid, + .set =3D set_uuid, + .set_default_value =3D set_default_uuid_auto, +}; + /* --- support for array properties --- */ =20 /* Used as an opaque for the object properties we add for each --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513867931884465.2983413415284; Thu, 21 Dec 2017 06:52:11 -0800 (PST) Received: from localhost ([::1]:53286 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS2CR-0000yO-He for importer@patchew.org; Thu, 21 Dec 2017 09:51:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45263) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1pY-0006xM-I9 for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:28:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1pV-0004vu-4L for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:28:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:8480) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1pU-0004vM-Rn for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:28:13 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 13FB55FD71; Thu, 21 Dec 2017 14:28:12 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3CD096363D; Thu, 21 Dec 2017 14:28:09 +0000 (UTC) Date: Thu, 21 Dec 2017 16:28:08 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-4-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 21 Dec 2017 14:28:12 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 03/25] vmgenid: use UUID property type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Igor Mammedov , Roman Kagan , Ben Warren , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Roman Kagan Switch vmgenid device to use the UUID property type introduced in the previous patch for its 'guid' property. One semantic change it introduces is that post-realize modification of 'guid' via HMP or QMP will now be rejected with an error; however, according to docs/specs/vmgenid.txt this is actually desirable. Signed-off-by: Roman Kagan Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Ben Warren Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/vmgenid.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/hw/acpi/vmgenid.c b/hw/acpi/vmgenid.c index 105044f..ba6f47b 100644 --- a/hw/acpi/vmgenid.c +++ b/hw/acpi/vmgenid.c @@ -162,21 +162,6 @@ static void vmgenid_update_guest(VmGenIdState *vms) } } =20 -static void vmgenid_set_guid(Object *obj, const char *value, Error **errp) -{ - VmGenIdState *vms =3D VMGENID(obj); - - if (!strcmp(value, "auto")) { - qemu_uuid_generate(&vms->guid); - } else if (qemu_uuid_parse(value, &vms->guid) < 0) { - error_setg(errp, "'%s. %s': Failed to parse GUID string: %s", - object_get_typename(OBJECT(vms)), VMGENID_GUID, value); - return; - } - - vmgenid_update_guest(vms); -} - /* After restoring an image, we need to update the guest memory and notify * it of a potential change to VM Generation ID */ @@ -224,23 +209,24 @@ static void vmgenid_realize(DeviceState *dev, Error *= *errp) } =20 qemu_register_reset(vmgenid_handle_reset, vms); + + vmgenid_update_guest(vms); } =20 +static Property vmgenid_device_properties[] =3D { + DEFINE_PROP_UUID(VMGENID_GUID, VmGenIdState, guid), + DEFINE_PROP_END_OF_LIST(), +}; + static void vmgenid_device_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); =20 dc->vmsd =3D &vmstate_vmgenid; dc->realize =3D vmgenid_realize; + dc->props =3D vmgenid_device_properties; dc->hotpluggable =3D false; set_bit(DEVICE_CATEGORY_MISC, dc->categories); - - object_class_property_add_str(klass, VMGENID_GUID, NULL, - vmgenid_set_guid, NULL); - object_class_property_set_description(klass, VMGENID_GUID, - "Set Global Unique Identifier " - "(big-endian) or auto for random value= ", - NULL); } =20 static const TypeInfo vmgenid_device_info =3D { --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513867514818754.0412079609997; Thu, 21 Dec 2017 06:45:14 -0800 (PST) Received: from localhost ([::1]:53217 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS25s-0003sq-Ds for importer@patchew.org; Thu, 21 Dec 2017 09:45:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1pd-00072C-SI for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:28:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1pc-00050t-Qw for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:28:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54294) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1pa-0004z8-KB; Thu, 21 Dec 2017 09:28:18 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C9C4BACB0; Thu, 21 Dec 2017 14:28:17 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with SMTP id ABC8D17490; Thu, 21 Dec 2017 14:28:12 +0000 (UTC) Date: Thu, 21 Dec 2017 16:28:12 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-5-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 21 Dec 2017 14:28:17 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 04/25] tests: add test to check VirtQueue object X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-block@nongnu.org, Prasad J Pandit , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Prasad J Pandit An uninitialised VirtQueue object or one with Vring.align field set to zero(0) could lead to arithmetic exceptions. Add a unit test to validate it. Signed-off-by: Prasad J Pandit Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi --- tests/virtio-blk-test.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c index e6fb9ba..45f368d 100644 --- a/tests/virtio-blk-test.c +++ b/tests/virtio-blk-test.c @@ -674,6 +674,30 @@ static void pci_hotplug(void) qtest_shutdown(qs); } =20 +/* + * Check that setting the vring addr on a non-existent virtqueue does + * not crash. + */ +static void test_nonexistent_virtqueue(void) +{ + QPCIBar bar0; + QOSState *qs; + QPCIDevice *dev; + + qs =3D pci_test_start(); + dev =3D qpci_device_find(qs->pcibus, QPCI_DEVFN(4, 0)); + g_assert(dev !=3D NULL); + + qpci_device_enable(dev); + bar0 =3D qpci_iomap(dev, 0, NULL); + + qpci_io_writeb(dev, bar0, VIRTIO_PCI_QUEUE_SEL, 2); + qpci_io_writel(dev, bar0, VIRTIO_PCI_QUEUE_PFN, 1); + + g_free(dev); + qtest_shutdown(qs); +} + static void mmio_basic(void) { QVirtioMMIODevice *dev; @@ -724,6 +748,7 @@ int main(int argc, char **argv) qtest_add_func("/virtio/blk/pci/basic", pci_basic); qtest_add_func("/virtio/blk/pci/indirect", pci_indirect); qtest_add_func("/virtio/blk/pci/config", pci_config); + qtest_add_func("/virtio/blk/pci/nxvirtq", test_nonexistent_virtque= ue); if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D= 0) { qtest_add_func("/virtio/blk/pci/msix", pci_msix); qtest_add_func("/virtio/blk/pci/idx", pci_idx); --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513868503613187.0694613021509; Thu, 21 Dec 2017 07:01:43 -0800 (PST) Received: from localhost ([::1]:53480 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS2Lk-0000tQ-7l for importer@patchew.org; Thu, 21 Dec 2017 10:01:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45450) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1pv-0007Fn-3N for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:28:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1ps-00058v-BZ for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:28:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54388) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1pl-00054X-QY; Thu, 21 Dec 2017 09:28:30 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 151B24B85; Thu, 21 Dec 2017 14:28:28 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with SMTP id 9CF382C323; Thu, 21 Dec 2017 14:28:18 +0000 (UTC) Date: Thu, 21 Dec 2017 16:28:17 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-6-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 21 Dec 2017 14:28:28 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 05/25] pci: Rename root bus initialization functions for clarity X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-s390x@nongnu.org, Cornelia Huck , Alexander Graf , Peter Xu , Christian Borntraeger , Paul Burton , qemu-arm@nongnu.org, =?utf-8?B?SGVydsOp?= Poussineau , Marcel Apfelbaum , qemu-ppc@nongnu.org, David Gibson , Yongbok Kim , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Gibson pci_bus_init(), pci_bus_new_inplace(), pci_bus_new() and pci_register_bus() are misleadingly named. They're not used for initializing *any* PCI bus, but only for a root PCI bus. Non-root buses - i.e. ones under a logical PCI to PCI bridge - are instead created with a direct qbus_create_inplace() (see pci_bridge_initfn()). This patch renames the functions to make it clear they're only used for a root bus. Signed-off-by: David Gibson Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Marcel Apfelbaum Reviewed-by: Peter Xu --- include/hw/pci/pci.h | 25 ++++++++++--------- hw/alpha/typhoon.c | 8 +++--- hw/mips/gt64xxx_pci.c | 12 ++++----- hw/pci-bridge/pci_expander_bridge.c | 4 +-- hw/pci-host/apb.c | 10 ++++---- hw/pci-host/bonito.c | 8 +++--- hw/pci-host/gpex.c | 6 ++--- hw/pci-host/grackle.c | 14 +++++------ hw/pci-host/piix.c | 4 +-- hw/pci-host/ppce500.c | 6 ++--- hw/pci-host/prep.c | 4 +-- hw/pci-host/q35.c | 7 +++--- hw/pci-host/uninorth.c | 24 +++++++++--------- hw/pci-host/versatile.c | 6 ++--- hw/pci-host/xilinx-pcie.c | 6 ++--- hw/pci/pci.c | 49 ++++++++++++++++++++-------------= ---- hw/ppc/ppc4xx_pci.c | 6 ++--- hw/ppc/spapr_pci.c | 8 +++--- hw/s390x/s390-pci-bus.c | 8 +++--- hw/sh4/sh_pci.c | 12 ++++----- 20 files changed, 116 insertions(+), 111 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 8d02a0a..870ebcf 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -400,26 +400,27 @@ typedef PCIINTxRoute (*pci_route_irq_fn)(void *opaque= , int pin); =20 bool pci_bus_is_express(PCIBus *bus); bool pci_bus_is_root(PCIBus *bus); -void pci_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent, - const char *name, +void pci_root_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *p= arent, + const char *name, + MemoryRegion *address_space_mem, + MemoryRegion *address_space_io, + uint8_t devfn_min, const char *typename); +PCIBus *pci_root_bus_new(DeviceState *parent, const char *name, MemoryRegion *address_space_mem, MemoryRegion *address_space_io, uint8_t devfn_min, const char *typename); -PCIBus *pci_bus_new(DeviceState *parent, const char *name, - MemoryRegion *address_space_mem, - MemoryRegion *address_space_io, - uint8_t devfn_min, const char *typename); void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, pci_map_irq_fn map_= irq, void *irq_opaque, int nirq); int pci_bus_get_irq_level(PCIBus *bus, int irq_num); /* 0 <=3D pin <=3D 3 0 =3D INTA, 1 =3D INTB, 2 =3D INTC, 3 =3D INTD */ int pci_swizzle_map_irq_fn(PCIDevice *pci_dev, int pin); -PCIBus *pci_register_bus(DeviceState *parent, const char *name, - pci_set_irq_fn set_irq, pci_map_irq_fn map_irq, - void *irq_opaque, - MemoryRegion *address_space_mem, - MemoryRegion *address_space_io, - uint8_t devfn_min, int nirq, const char *typename= ); +PCIBus *pci_register_root_bus(DeviceState *parent, const char *name, + pci_set_irq_fn set_irq, pci_map_irq_fn map_i= rq, + void *irq_opaque, + MemoryRegion *address_space_mem, + MemoryRegion *address_space_io, + uint8_t devfn_min, int nirq, + const char *typename); void pci_bus_set_route_irq_fn(PCIBus *, pci_route_irq_fn); PCIINTxRoute pci_device_route_intx_to_irq(PCIDevice *dev, int pin); bool pci_intx_route_changed(PCIINTxRoute *old, PCIINTxRoute *new); diff --git a/hw/alpha/typhoon.c b/hw/alpha/typhoon.c index ae11e01..6a40869 100644 --- a/hw/alpha/typhoon.c +++ b/hw/alpha/typhoon.c @@ -881,10 +881,10 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **is= a_bus, memory_region_add_subregion(addr_space, 0x801fc000000ULL, &s->pchip.reg_io); =20 - b =3D pci_register_bus(dev, "pci", - typhoon_set_irq, sys_map_irq, s, - &s->pchip.reg_mem, &s->pchip.reg_io, - 0, 64, TYPE_PCI_BUS); + b =3D pci_register_root_bus(dev, "pci", + typhoon_set_irq, sys_map_irq, s, + &s->pchip.reg_mem, &s->pchip.reg_io, + 0, 64, TYPE_PCI_BUS); phb->bus =3D b; qdev_init_nofail(dev); =20 diff --git a/hw/mips/gt64xxx_pci.c b/hw/mips/gt64xxx_pci.c index 5a9dad9..a9c222a 100644 --- a/hw/mips/gt64xxx_pci.c +++ b/hw/mips/gt64xxx_pci.c @@ -1171,12 +1171,12 @@ PCIBus *gt64120_register(qemu_irq *pic) phb =3D PCI_HOST_BRIDGE(dev); memory_region_init(&d->pci0_mem, OBJECT(dev), "pci0-mem", UINT32_MAX); address_space_init(&d->pci0_mem_as, &d->pci0_mem, "pci0-mem"); - phb->bus =3D pci_register_bus(dev, "pci", - gt64120_pci_set_irq, gt64120_pci_map_irq, - pic, - &d->pci0_mem, - get_system_io(), - PCI_DEVFN(18, 0), 4, TYPE_PCI_BUS); + phb->bus =3D pci_register_root_bus(dev, "pci", + gt64120_pci_set_irq, gt64120_pci_map_= irq, + pic, + &d->pci0_mem, + get_system_io(), + PCI_DEVFN(18, 0), 4, TYPE_PCI_BUS); qdev_init_nofail(dev); memory_region_init_io(&d->ISD_mem, OBJECT(dev), &isd_mem_ops, d, "isd-= mem", 0x1000); =20 diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expand= er_bridge.c index 8c8ac73..b2fa829 100644 --- a/hw/pci-bridge/pci_expander_bridge.c +++ b/hw/pci-bridge/pci_expander_bridge.c @@ -230,9 +230,9 @@ static void pxb_dev_realize_common(PCIDevice *dev, bool= pcie, Error **errp) =20 ds =3D qdev_create(NULL, TYPE_PXB_HOST); if (pcie) { - bus =3D pci_bus_new(ds, dev_name, NULL, NULL, 0, TYPE_PXB_PCIE_BUS= ); + bus =3D pci_root_bus_new(ds, dev_name, NULL, NULL, 0, TYPE_PXB_PCI= E_BUS); } else { - bus =3D pci_bus_new(ds, "pxb-internal", NULL, NULL, 0, TYPE_PXB_BU= S); + bus =3D pci_root_bus_new(ds, "pxb-internal", NULL, NULL, 0, TYPE_P= XB_BUS); bds =3D qdev_create(BUS(bus), "pci-bridge"); bds->id =3D dev_name; qdev_prop_set_uint8(bds, PCI_BRIDGE_DEV_PROP_CHASSIS_NR, pxb->bus_= nr); diff --git a/hw/pci-host/apb.c b/hw/pci-host/apb.c index 64025cd..1df9984 100644 --- a/hw/pci-host/apb.c +++ b/hw/pci-host/apb.c @@ -714,11 +714,11 @@ PCIBus *pci_apb_init(hwaddr special_base, dev =3D qdev_create(NULL, TYPE_APB); d =3D APB_DEVICE(dev); phb =3D PCI_HOST_BRIDGE(dev); - phb->bus =3D pci_register_bus(DEVICE(phb), "pci", - pci_apb_set_irq, pci_apb_map_irq, d, - &d->pci_mmio, - &d->pci_ioport, - 0, 32, TYPE_PCI_BUS); + phb->bus =3D pci_register_root_bus(DEVICE(phb), "pci", + pci_apb_set_irq, pci_apb_map_irq, d, + &d->pci_mmio, + &d->pci_ioport, + 0, 32, TYPE_PCI_BUS); qdev_init_nofail(dev); s =3D SYS_BUS_DEVICE(dev); /* apb_config */ diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c index 9f61e27..f08593f 100644 --- a/hw/pci-host/bonito.c +++ b/hw/pci-host/bonito.c @@ -714,10 +714,10 @@ static int bonito_pcihost_initfn(SysBusDevice *dev) { PCIHostState *phb =3D PCI_HOST_BRIDGE(dev); =20 - phb->bus =3D pci_register_bus(DEVICE(dev), "pci", - pci_bonito_set_irq, pci_bonito_map_irq, de= v, - get_system_memory(), get_system_io(), - 0x28, 32, TYPE_PCI_BUS); + phb->bus =3D pci_register_root_bus(DEVICE(dev), "pci", + pci_bonito_set_irq, pci_bonito_map_ir= q, + dev, get_system_memory(), get_system_= io(), + 0x28, 32, TYPE_PCI_BUS); =20 return 0; } diff --git a/hw/pci-host/gpex.c b/hw/pci-host/gpex.c index edf305b..2583b15 100644 --- a/hw/pci-host/gpex.c +++ b/hw/pci-host/gpex.c @@ -89,9 +89,9 @@ static void gpex_host_realize(DeviceState *dev, Error **e= rrp) s->irq_num[i] =3D -1; } =20 - pci->bus =3D pci_register_bus(dev, "pcie.0", gpex_set_irq, - pci_swizzle_map_irq_fn, s, &s->io_mmio, - &s->io_ioport, 0, 4, TYPE_PCIE_BUS); + pci->bus =3D pci_register_root_bus(dev, "pcie.0", gpex_set_irq, + pci_swizzle_map_irq_fn, s, &s->io_mmi= o, + &s->io_ioport, 0, 4, TYPE_PCIE_BUS); =20 qdev_set_parent_bus(DEVICE(&s->gpex_root), BUS(pci->bus)); pci_bus_set_route_irq_fn(pci->bus, gpex_route_intx_pin_to_irq); diff --git a/hw/pci-host/grackle.c b/hw/pci-host/grackle.c index 38cd279..3caf1cc 100644 --- a/hw/pci-host/grackle.c +++ b/hw/pci-host/grackle.c @@ -82,13 +82,13 @@ PCIBus *pci_grackle_init(uint32_t base, qemu_irq *pic, memory_region_add_subregion(address_space_mem, 0x80000000ULL, &d->pci_hole); =20 - phb->bus =3D pci_register_bus(dev, NULL, - pci_grackle_set_irq, - pci_grackle_map_irq, - pic, - &d->pci_mmio, - address_space_io, - 0, 4, TYPE_PCI_BUS); + phb->bus =3D pci_register_root_bus(dev, NULL, + pci_grackle_set_irq, + pci_grackle_map_irq, + pic, + &d->pci_mmio, + address_space_io, + 0, 4, TYPE_PCI_BUS); =20 pci_create_simple(phb->bus, 0, "grackle"); qdev_init_nofail(dev); diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c index a684a7c..cf90701 100644 --- a/hw/pci-host/piix.c +++ b/hw/pci-host/piix.c @@ -361,8 +361,8 @@ PCIBus *i440fx_init(const char *host_type, const char *= pci_type, =20 dev =3D qdev_create(NULL, host_type); s =3D PCI_HOST_BRIDGE(dev); - b =3D pci_bus_new(dev, NULL, pci_address_space, - address_space_io, 0, TYPE_PCI_BUS); + b =3D pci_root_bus_new(dev, NULL, pci_address_space, + address_space_io, 0, TYPE_PCI_BUS); s->bus =3D b; object_property_add_child(qdev_get_machine(), "i440fx", OBJECT(dev), N= ULL); qdev_init_nofail(dev); diff --git a/hw/pci-host/ppce500.c b/hw/pci-host/ppce500.c index 39cd244..67edbf7 100644 --- a/hw/pci-host/ppce500.c +++ b/hw/pci-host/ppce500.c @@ -465,9 +465,9 @@ static int e500_pcihost_initfn(SysBusDevice *dev) /* PIO lives at the bottom of our bus space */ memory_region_add_subregion_overlap(&s->busmem, 0, &s->pio, -2); =20 - b =3D pci_register_bus(DEVICE(dev), NULL, mpc85xx_pci_set_irq, - mpc85xx_pci_map_irq, s, &s->busmem, &s->pio, - PCI_DEVFN(s->first_slot, 0), 4, TYPE_PCI_BUS); + b =3D pci_register_root_bus(DEVICE(dev), NULL, mpc85xx_pci_set_irq, + mpc85xx_pci_map_irq, s, &s->busmem, &s->pio, + PCI_DEVFN(s->first_slot, 0), 4, TYPE_PCI_BUS= ); h->bus =3D b; =20 /* Set up PCI view of memory */ diff --git a/hw/pci-host/prep.c b/hw/pci-host/prep.c index 92eed0f..01f67f9 100644 --- a/hw/pci-host/prep.c +++ b/hw/pci-host/prep.c @@ -269,8 +269,8 @@ static void raven_pcihost_initfn(Object *obj) memory_region_add_subregion_overlap(address_space_mem, 0x80000000, &s->pci_io_non_contiguous, 1); memory_region_add_subregion(address_space_mem, 0xc0000000, &s->pci_mem= ory); - pci_bus_new_inplace(&s->pci_bus, sizeof(s->pci_bus), DEVICE(obj), NULL, - &s->pci_memory, &s->pci_io, 0, TYPE_PCI_BUS); + pci_root_bus_new_inplace(&s->pci_bus, sizeof(s->pci_bus), DEVICE(obj),= NULL, + &s->pci_memory, &s->pci_io, 0, TYPE_PCI_BUS); =20 /* Bus master address space */ memory_region_init(&s->bm, obj, "bm-raven", UINT32_MAX); diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index 6cb9a8d..a36a119 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -51,9 +51,10 @@ static void q35_host_realize(DeviceState *dev, Error **e= rrp) sysbus_add_io(sbd, MCH_HOST_BRIDGE_CONFIG_DATA, &pci->data_mem); sysbus_init_ioports(sbd, MCH_HOST_BRIDGE_CONFIG_DATA, 4); =20 - pci->bus =3D pci_bus_new(DEVICE(s), "pcie.0", - s->mch.pci_address_space, s->mch.address_space_= io, - 0, TYPE_PCIE_BUS); + pci->bus =3D pci_root_bus_new(DEVICE(s), "pcie.0", + s->mch.pci_address_space, + s->mch.address_space_io, + 0, TYPE_PCIE_BUS); PC_MACHINE(qdev_get_machine())->bus =3D pci->bus; qdev_set_parent_bus(DEVICE(&s->mch), BUS(pci->bus)); qdev_init_nofail(DEVICE(&s->mch)); diff --git a/hw/pci-host/uninorth.c b/hw/pci-host/uninorth.c index ea5c265..5d8ccaa 100644 --- a/hw/pci-host/uninorth.c +++ b/hw/pci-host/uninorth.c @@ -233,12 +233,12 @@ PCIBus *pci_pmac_init(qemu_irq *pic, memory_region_add_subregion(address_space_mem, 0x80000000ULL, &d->pci_hole); =20 - h->bus =3D pci_register_bus(dev, NULL, - pci_unin_set_irq, pci_unin_map_irq, - pic, - &d->pci_mmio, - address_space_io, - PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); + h->bus =3D pci_register_root_bus(dev, NULL, + pci_unin_set_irq, pci_unin_map_irq, + pic, + &d->pci_mmio, + address_space_io, + PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); =20 #if 0 pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north"); @@ -299,12 +299,12 @@ PCIBus *pci_pmac_u3_init(qemu_irq *pic, memory_region_add_subregion(address_space_mem, 0x80000000ULL, &d->pci_hole); =20 - h->bus =3D pci_register_bus(dev, NULL, - pci_unin_set_irq, pci_unin_map_irq, - pic, - &d->pci_mmio, - address_space_io, - PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); + h->bus =3D pci_register_root_bus(dev, NULL, + pci_unin_set_irq, pci_unin_map_irq, + pic, + &d->pci_mmio, + address_space_io, + PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); =20 sysbus_mmio_map(s, 0, 0xf0800000); sysbus_mmio_map(s, 1, 0xf0c00000); diff --git a/hw/pci-host/versatile.c b/hw/pci-host/versatile.c index 6394a52..8803ada 100644 --- a/hw/pci-host/versatile.c +++ b/hw/pci-host/versatile.c @@ -399,9 +399,9 @@ static void pci_vpb_realize(DeviceState *dev, Error **e= rrp) memory_region_init(&s->pci_io_space, OBJECT(s), "pci_io", 1ULL << 32); memory_region_init(&s->pci_mem_space, OBJECT(s), "pci_mem", 1ULL << 32= ); =20 - pci_bus_new_inplace(&s->pci_bus, sizeof(s->pci_bus), dev, "pci", - &s->pci_mem_space, &s->pci_io_space, - PCI_DEVFN(11, 0), TYPE_PCI_BUS); + pci_root_bus_new_inplace(&s->pci_bus, sizeof(s->pci_bus), dev, "pci", + &s->pci_mem_space, &s->pci_io_space, + PCI_DEVFN(11, 0), TYPE_PCI_BUS); h->bus =3D &s->pci_bus; =20 object_initialize(&s->pci_dev, sizeof(s->pci_dev), TYPE_VERSATILE_PCI_= HOST); diff --git a/hw/pci-host/xilinx-pcie.c b/hw/pci-host/xilinx-pcie.c index 7659253..d2f88d1 100644 --- a/hw/pci-host/xilinx-pcie.c +++ b/hw/pci-host/xilinx-pcie.c @@ -129,9 +129,9 @@ static void xilinx_pcie_host_realize(DeviceState *dev, = Error **errp) sysbus_init_mmio(sbd, &pex->mmio); sysbus_init_mmio(sbd, &s->mmio); =20 - pci->bus =3D pci_register_bus(dev, s->name, xilinx_pcie_set_irq, - pci_swizzle_map_irq_fn, s, &s->mmio, - &s->io, 0, 4, TYPE_PCIE_BUS); + pci->bus =3D pci_register_root_bus(dev, s->name, xilinx_pcie_set_irq, + pci_swizzle_map_irq_fn, s, &s->mmio, + &s->io, 0, 4, TYPE_PCIE_BUS); =20 qdev_set_parent_bus(DEVICE(&s->root), BUS(pci->bus)); qdev_init_nofail(DEVICE(&s->root)); diff --git a/hw/pci/pci.c b/hw/pci/pci.c index b2d139b..232e7da 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -376,10 +376,10 @@ const char *pci_root_bus_path(PCIDevice *dev) return rootbus->qbus.name; } =20 -static void pci_bus_init(PCIBus *bus, DeviceState *parent, - MemoryRegion *address_space_mem, - MemoryRegion *address_space_io, - uint8_t devfn_min) +static void pci_root_bus_init(PCIBus *bus, DeviceState *parent, + MemoryRegion *address_space_mem, + MemoryRegion *address_space_io, + uint8_t devfn_min) { assert(PCI_FUNC(devfn_min) =3D=3D 0); bus->devfn_min =3D devfn_min; @@ -403,25 +403,27 @@ bool pci_bus_is_root(PCIBus *bus) return PCI_BUS_GET_CLASS(bus)->is_root(bus); } =20 -void pci_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent, - const char *name, - MemoryRegion *address_space_mem, - MemoryRegion *address_space_io, - uint8_t devfn_min, const char *typename) +void pci_root_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *p= arent, + const char *name, + MemoryRegion *address_space_mem, + MemoryRegion *address_space_io, + uint8_t devfn_min, const char *typename) { qbus_create_inplace(bus, bus_size, typename, parent, name); - pci_bus_init(bus, parent, address_space_mem, address_space_io, devfn_m= in); + pci_root_bus_init(bus, parent, address_space_mem, address_space_io, + devfn_min); } =20 -PCIBus *pci_bus_new(DeviceState *parent, const char *name, - MemoryRegion *address_space_mem, - MemoryRegion *address_space_io, - uint8_t devfn_min, const char *typename) +PCIBus *pci_root_bus_new(DeviceState *parent, const char *name, + MemoryRegion *address_space_mem, + MemoryRegion *address_space_io, + uint8_t devfn_min, const char *typename) { PCIBus *bus; =20 bus =3D PCI_BUS(qbus_create(typename, parent, name)); - pci_bus_init(bus, parent, address_space_mem, address_space_io, devfn_m= in); + pci_root_bus_init(bus, parent, address_space_mem, address_space_io, + devfn_min); return bus; } =20 @@ -435,17 +437,18 @@ void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq= , pci_map_irq_fn map_irq, bus->irq_count =3D g_malloc0(nirq * sizeof(bus->irq_count[0])); } =20 -PCIBus *pci_register_bus(DeviceState *parent, const char *name, - pci_set_irq_fn set_irq, pci_map_irq_fn map_irq, - void *irq_opaque, - MemoryRegion *address_space_mem, - MemoryRegion *address_space_io, - uint8_t devfn_min, int nirq, const char *typename) +PCIBus *pci_register_root_bus(DeviceState *parent, const char *name, + pci_set_irq_fn set_irq, pci_map_irq_fn map_i= rq, + void *irq_opaque, + MemoryRegion *address_space_mem, + MemoryRegion *address_space_io, + uint8_t devfn_min, int nirq, + const char *typename) { PCIBus *bus; =20 - bus =3D pci_bus_new(parent, name, address_space_mem, - address_space_io, devfn_min, typename); + bus =3D pci_root_bus_new(parent, name, address_space_mem, + address_space_io, devfn_min, typename); pci_bus_irqs(bus, set_irq, map_irq, irq_opaque, nirq); return bus; } diff --git a/hw/ppc/ppc4xx_pci.c b/hw/ppc/ppc4xx_pci.c index 4765dce..b7642ba 100644 --- a/hw/ppc/ppc4xx_pci.c +++ b/hw/ppc/ppc4xx_pci.c @@ -314,9 +314,9 @@ static int ppc4xx_pcihost_initfn(SysBusDevice *dev) sysbus_init_irq(dev, &s->irq[i]); } =20 - b =3D pci_register_bus(DEVICE(dev), NULL, ppc4xx_pci_set_irq, - ppc4xx_pci_map_irq, s->irq, get_system_memory(), - get_system_io(), 0, 4, TYPE_PCI_BUS); + b =3D pci_register_root_bus(DEVICE(dev), NULL, ppc4xx_pci_set_irq, + ppc4xx_pci_map_irq, s->irq, get_system_memor= y(), + get_system_io(), 0, 4, TYPE_PCI_BUS); h->bus =3D b; =20 pci_create_simple(b, 0, "ppc4xx-host-bridge"); diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 5a3122a..9262682 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1621,10 +1621,10 @@ static void spapr_phb_realize(DeviceState *dev, Err= or **errp) memory_region_add_subregion(get_system_memory(), sphb->io_win_addr, &sphb->iowindow); =20 - bus =3D pci_register_bus(dev, NULL, - pci_spapr_set_irq, pci_spapr_map_irq, sphb, - &sphb->memspace, &sphb->iospace, - PCI_DEVFN(0, 0), PCI_NUM_PINS, TYPE_PCI_BUS); + bus =3D pci_register_root_bus(dev, NULL, + pci_spapr_set_irq, pci_spapr_map_irq, sphb, + &sphb->memspace, &sphb->iospace, + PCI_DEVFN(0, 0), PCI_NUM_PINS, TYPE_PCI_BU= S); phb->bus =3D bus; qbus_set_hotplug_handler(BUS(phb->bus), DEVICE(sphb), NULL); =20 diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 2b1e140..347329d 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -554,10 +554,10 @@ static int s390_pcihost_init(SysBusDevice *dev) =20 DPRINTF("host_init\n"); =20 - b =3D pci_register_bus(DEVICE(dev), NULL, - s390_pci_set_irq, s390_pci_map_irq, NULL, - get_system_memory(), get_system_io(), 0, 64, - TYPE_PCI_BUS); + b =3D pci_register_root_bus(DEVICE(dev), NULL, + s390_pci_set_irq, s390_pci_map_irq, NULL, + get_system_memory(), get_system_io(), 0, 64, + TYPE_PCI_BUS); pci_setup_iommu(b, s390_pci_dma_iommu, s); =20 bus =3D BUS(b); diff --git a/hw/sh4/sh_pci.c b/hw/sh4/sh_pci.c index cbb01af..4ec2e35 100644 --- a/hw/sh4/sh_pci.c +++ b/hw/sh4/sh_pci.c @@ -131,12 +131,12 @@ static int sh_pci_device_init(SysBusDevice *dev) for (i =3D 0; i < 4; i++) { sysbus_init_irq(dev, &s->irq[i]); } - phb->bus =3D pci_register_bus(DEVICE(dev), "pci", - sh_pci_set_irq, sh_pci_map_irq, - s->irq, - get_system_memory(), - get_system_io(), - PCI_DEVFN(0, 0), 4, TYPE_PCI_BUS); + phb->bus =3D pci_register_root_bus(DEVICE(dev), "pci", + sh_pci_set_irq, sh_pci_map_irq, + s->irq, + get_system_memory(), + get_system_io(), + PCI_DEVFN(0, 0), 4, TYPE_PCI_BUS); memory_region_init_io(&s->memconfig_p4, OBJECT(s), &sh_pci_reg_ops, s, "sh_pci", 0x224); memory_region_init_alias(&s->memconfig_a7, OBJECT(s), "sh_pci.2", --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513866807500795.6286864490634; Thu, 21 Dec 2017 06:33:27 -0800 (PST) Received: from localhost ([::1]:53075 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1uI-0002AY-Ej for importer@patchew.org; Thu, 21 Dec 2017 09:33:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45479) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1px-0007I3-2Z for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:28:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1pv-0005Cf-Ph for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:28:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54290) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1pv-0005Bi-GC for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:28:39 -0500 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 A2E2581DE7; Thu, 21 Dec 2017 14:28:38 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with SMTP id 05D2A5C2F0; Thu, 21 Dec 2017 14:28:28 +0000 (UTC) Date: Thu, 21 Dec 2017 16:28:28 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-7-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent 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.25]); Thu, 21 Dec 2017 14:28:38 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 06/25] pci: Move bridge data structures from pci_bus.h to pci_bridge.h X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcel Apfelbaum , Peter Maydell , Peter Xu , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Gibson include/hw/pci/pci_bus.h contains several data structures related to PCI bridges that aren't needed by most users of pci_bus.h. We already have a pci_bridge.h, so move them there. Signed-off-by: David Gibson Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Marcel Apfelbaum Reviewed-by: Peter Xu --- include/hw/pci-host/xilinx-pcie.h | 2 +- include/hw/pci/pci_bridge.h | 48 ++++++++++++++++++++++++++++++++++++ include/hw/pci/pci_bus.h | 51 ++---------------------------------= ---- 3 files changed, 51 insertions(+), 50 deletions(-) diff --git a/include/hw/pci-host/xilinx-pcie.h b/include/hw/pci-host/xilinx= -pcie.h index bec66b2..74c04dc 100644 --- a/include/hw/pci-host/xilinx-pcie.h +++ b/include/hw/pci-host/xilinx-pcie.h @@ -23,7 +23,7 @@ #include "hw/hw.h" #include "hw/sysbus.h" #include "hw/pci/pci.h" -#include "hw/pci/pci_bus.h" +#include "hw/pci/pci_bridge.h" #include "hw/pci/pcie_host.h" =20 #define TYPE_XILINX_PCIE_HOST "xilinx-pcie-host" diff --git a/include/hw/pci/pci_bridge.h b/include/hw/pci/pci_bridge.h index 1acadc2..9b44ffd 100644 --- a/include/hw/pci/pci_bridge.h +++ b/include/hw/pci/pci_bridge.h @@ -27,6 +27,54 @@ #define QEMU_PCI_BRIDGE_H =20 #include "hw/pci/pci.h" +#include "hw/pci/pci_bus.h" + +typedef struct PCIBridgeWindows PCIBridgeWindows; + +/* + * Aliases for each of the address space windows that the bridge + * can forward. Mapped into the bridge's parent's address space, + * as subregions. + */ +struct PCIBridgeWindows { + MemoryRegion alias_pref_mem; + MemoryRegion alias_mem; + MemoryRegion alias_io; + /* + * When bridge control VGA forwarding is enabled, bridges will + * provide positive decode on the PCI VGA defined I/O port and + * MMIO ranges. When enabled forwarding is only qualified on the + * I/O and memory enable bits in the bridge command register. + */ + MemoryRegion alias_vga[QEMU_PCI_VGA_NUM_REGIONS]; +}; + +#define TYPE_PCI_BRIDGE "base-pci-bridge" +#define PCI_BRIDGE(obj) OBJECT_CHECK(PCIBridge, (obj), TYPE_PCI_BRIDGE) + +struct PCIBridge { + /*< private >*/ + PCIDevice parent_obj; + /*< public >*/ + + /* private member */ + PCIBus sec_bus; + /* + * Memory regions for the bridge's address spaces. These regions are = not + * directly added to system_memory/system_io or its descendants. + * Bridge's secondary bus points to these, so that devices + * under the bridge see these regions as its address spaces. + * The regions are as large as the entire address space - + * they don't take into account any windows. + */ + MemoryRegion address_space_mem; + MemoryRegion address_space_io; + + PCIBridgeWindows *windows; + + pci_map_irq_fn map_irq; + const char *bus_name; +}; =20 #define PCI_BRIDGE_DEV_PROP_CHASSIS_NR "chassis_nr" #define PCI_BRIDGE_DEV_PROP_MSI "msi" diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h index bc34fd0..b7da8f5 100644 --- a/include/hw/pci/pci_bus.h +++ b/include/hw/pci/pci_bus.h @@ -2,10 +2,10 @@ #define QEMU_PCI_BUS_H =20 /* - * PCI Bus and Bridge datastructures. + * PCI Bus datastructures. * * Do not access the following members directly; - * use accessor functions in pci.h, pci_bridge.h + * use accessor functions in pci.h */ =20 typedef struct PCIBusClass { @@ -44,51 +44,4 @@ struct PCIBus { Notifier machine_done; }; =20 -typedef struct PCIBridgeWindows PCIBridgeWindows; - -/* - * Aliases for each of the address space windows that the bridge - * can forward. Mapped into the bridge's parent's address space, - * as subregions. - */ -struct PCIBridgeWindows { - MemoryRegion alias_pref_mem; - MemoryRegion alias_mem; - MemoryRegion alias_io; - /* - * When bridge control VGA forwarding is enabled, bridges will - * provide positive decode on the PCI VGA defined I/O port and - * MMIO ranges. When enabled forwarding is only qualified on the - * I/O and memory enable bits in the bridge command register. - */ - MemoryRegion alias_vga[QEMU_PCI_VGA_NUM_REGIONS]; -}; - -#define TYPE_PCI_BRIDGE "base-pci-bridge" -#define PCI_BRIDGE(obj) OBJECT_CHECK(PCIBridge, (obj), TYPE_PCI_BRIDGE) - -struct PCIBridge { - /*< private >*/ - PCIDevice parent_obj; - /*< public >*/ - - /* private member */ - PCIBus sec_bus; - /* - * Memory regions for the bridge's address spaces. These regions are = not - * directly added to system_memory/system_io or its descendants. - * Bridge's secondary bus points to these, so that devices - * under the bridge see these regions as its address spaces. - * The regions are as large as the entire address space - - * they don't take into account any windows. - */ - MemoryRegion address_space_mem; - MemoryRegion address_space_io; - - PCIBridgeWindows *windows; - - pci_map_irq_fn map_irq; - const char *bus_name; -}; - #endif /* QEMU_PCI_BUS_H */ --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513866999113282.79593835628566; Thu, 21 Dec 2017 06:36:39 -0800 (PST) Received: from localhost ([::1]:53097 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1xV-0004vc-Q7 for importer@patchew.org; Thu, 21 Dec 2017 09:36:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1qC-0007Y6-ON for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:28:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1qB-0005Ol-Ef for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:28:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51770) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1q6-0005L9-1r; Thu, 21 Dec 2017 09:28:50 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1A4CDC01FA8A; Thu, 21 Dec 2017 14:28:49 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with SMTP id 643325C6D4; Thu, 21 Dec 2017 14:28:39 +0000 (UTC) Date: Thu, 21 Dec 2017 16:28:38 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-8-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 21 Dec 2017 14:28:49 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 07/25] pci: Add pci_dev_bus_num() helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Hannes Reinecke , Stefano Stabellini , xen-devel@lists.xenproject.org, qemu-block@nongnu.org, Cornelia Huck , Alexander Graf , Peter Xu , Christian Borntraeger , qemu-s390x@nongnu.org, Anthony Perard , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Gibson A fair proportion of the users of pci_bus_num() want to get the bus number on a specific device, so first have to look up the bus from the device then call it. This adds a helper to do that (since we're going to make looking up the bus slightly more verbose). Signed-off-by: David Gibson Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Marcel Apfelbaum Reviewed-by: Peter Xu --- include/hw/pci/pci.h | 5 +++++ include/hw/xen/xen_common.h | 8 ++++---- hw/pci/pcie_aer.c | 2 +- hw/s390x/s390-pci-bus.c | 2 +- hw/scsi/megasas.c | 2 +- hw/scsi/mptsas.c | 2 +- hw/xen/xen_pt.c | 6 +++--- 7 files changed, 16 insertions(+), 11 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 870ebcf..e451235 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -436,6 +436,11 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *ro= otbus, PCIDevice *pci_vga_init(PCIBus *bus); =20 int pci_bus_num(PCIBus *s); +static inline int pci_dev_bus_num(const PCIDevice *dev) +{ + return pci_bus_num(dev->bus); +} + int pci_bus_numa_node(PCIBus *bus); void pci_for_each_device(PCIBus *bus, int bus_num, void (*fn)(PCIBus *bus, PCIDevice *d, void *opaqu= e), diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h index 86c7f26..64a978e 100644 --- a/include/hw/xen/xen_common.h +++ b/include/hw/xen/xen_common.h @@ -542,10 +542,10 @@ static inline void xen_map_pcidev(domid_t dom, return; } =20 - trace_xen_map_pcidev(ioservid, pci_bus_num(pci_dev->bus), + trace_xen_map_pcidev(ioservid, pci_dev_bus_num(pci_dev), PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn= )); xendevicemodel_map_pcidev_to_ioreq_server(xen_dmod, dom, ioservid, 0, - pci_bus_num(pci_dev->bus), + pci_dev_bus_num(pci_dev), PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn)); } @@ -558,10 +558,10 @@ static inline void xen_unmap_pcidev(domid_t dom, return; } =20 - trace_xen_unmap_pcidev(ioservid, pci_bus_num(pci_dev->bus), + trace_xen_unmap_pcidev(ioservid, pci_dev_bus_num(pci_dev), PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->dev= fn)); xendevicemodel_unmap_pcidev_from_ioreq_server(xen_dmod, dom, ioservid,= 0, - pci_bus_num(pci_dev->bus= ), + pci_dev_bus_num(pci_dev), PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn)= ); } diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c index 9720074..21f896a 100644 --- a/hw/pci/pcie_aer.c +++ b/hw/pci/pcie_aer.c @@ -1025,7 +1025,7 @@ static int do_pcie_aer_inject_error(Monitor *mon, } details->id =3D id; details->root_bus =3D pci_root_bus_path(dev); - details->bus =3D pci_bus_num(dev->bus); + details->bus =3D pci_dev_bus_num(dev); details->devfn =3D dev->devfn; =20 return 0; diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 347329d..f64ad59 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -692,7 +692,7 @@ static void s390_pcihost_hot_plug(HotplugHandler *hotpl= ug_dev, /* In the case the PCI device does not define an id */ /* we generate one based on the PCI address */ dev->id =3D g_strdup_printf("auto_%02x:%02x.%01x", - pci_bus_num(pdev->bus), + pci_dev_bus_num(pdev), PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); } diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index d5eae62..3e38e9e 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -2372,7 +2372,7 @@ static void megasas_scsi_realize(PCIDevice *dev, Erro= r **errp) if (!s->sas_addr) { s->sas_addr =3D ((NAA_LOCALLY_ASSIGNED_ID << 24) | IEEE_COMPANY_LOCALLY_ASSIGNED) << 36; - s->sas_addr |=3D (pci_bus_num(dev->bus) << 16); + s->sas_addr |=3D (pci_dev_bus_num(dev) << 16); s->sas_addr |=3D (PCI_SLOT(dev->devfn) << 8); s->sas_addr |=3D PCI_FUNC(dev->devfn); } diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c index f6db1b0..3f061f3 100644 --- a/hw/scsi/mptsas.c +++ b/hw/scsi/mptsas.c @@ -1312,7 +1312,7 @@ static void mptsas_scsi_realize(PCIDevice *dev, Error= **errp) if (!s->sas_addr) { s->sas_addr =3D ((NAA_LOCALLY_ASSIGNED_ID << 24) | IEEE_COMPANY_LOCALLY_ASSIGNED) << 36; - s->sas_addr |=3D (pci_bus_num(dev->bus) << 16); + s->sas_addr |=3D (pci_dev_bus_num(dev) << 16); s->sas_addr |=3D (PCI_SLOT(dev->devfn) << 8); s->sas_addr |=3D PCI_FUNC(dev->devfn); } diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index 9bba717..6236f0c 100644 --- a/hw/xen/xen_pt.c +++ b/hw/xen/xen_pt.c @@ -73,7 +73,7 @@ void xen_pt_log(const PCIDevice *d, const char *f, ...) =20 va_start(ap, f); if (d) { - fprintf(stderr, "[%02x:%02x.%d] ", pci_bus_num(d->bus), + fprintf(stderr, "[%02x:%02x.%d] ", pci_dev_bus_num(d), PCI_SLOT(d->devfn), PCI_FUNC(d->devfn)); } vfprintf(stderr, f, ap); @@ -711,7 +711,7 @@ static void xen_pt_destroy(PCIDevice *d) { intx =3D xen_pt_pci_intx(s); rc =3D xc_domain_unbind_pt_irq(xen_xc, xen_domid, machine_irq, PT_IRQ_TYPE_PCI, - pci_bus_num(d->bus), + pci_dev_bus_num(d), PCI_SLOT(s->dev.devfn), intx, 0 /* isa_irq */); @@ -867,7 +867,7 @@ static void xen_pt_realize(PCIDevice *d, Error **errp) uint8_t e_intx =3D xen_pt_pci_intx(s); =20 rc =3D xc_domain_bind_pt_pci_irq(xen_xc, xen_domid, machine_irq, - pci_bus_num(d->bus), + pci_dev_bus_num(d), PCI_SLOT(d->devfn), e_intx); if (rc < 0) { --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513867566927984.949455445294; Thu, 21 Dec 2017 06:46:06 -0800 (PST) Received: from localhost ([::1]:53222 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS26i-0004Vn-HI for importer@patchew.org; Thu, 21 Dec 2017 09:46:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1qY-0007qL-FA for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1qU-0005cp-Sl for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57806) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1qN-0005Vy-8d; Thu, 21 Dec 2017 09:29:07 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4464080B2A; Thu, 21 Dec 2017 14:29:06 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with SMTP id A29772C333; Thu, 21 Dec 2017 14:28:49 +0000 (UTC) Date: Thu, 21 Dec 2017 16:28:49 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-9-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 21 Dec 2017 14:29:06 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 08/25] pci: Eliminate redundant PCIDevice::bus pointer X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Dmitry Fleytman , Stefano Stabellini , Eduardo Habkost , Christian Borntraeger , qemu-s390x@nongnu.org, Jason Wang , Cornelia Huck , Alexander Graf , Peter Xu , Anthony Perard , Alex Williamson , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Gerd Hoffmann , Paolo Bonzini , Marcel Apfelbaum , Igor Mammedov , Richard Henderson , xen-devel@lists.xenproject.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Gibson The bus pointer in PCIDevice is basically redundant with QOM information. It's always initialized to the qdev_get_parent_bus(), the only difference is the type. Therefore this patch eliminates the field, instead creating a pci_get_bus() helper to do the type mangling to derive it conveniently from the QOM Device object underneath. Signed-off-by: David Gibson Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Eduardo Habkost Reviewed-by: Marcel Apfelbaum Reviewed-by: Peter Xu --- include/hw/pci/pci.h | 9 +++-- hw/acpi/pcihp.c | 4 +- hw/acpi/piix4.c | 7 ++-- hw/i386/xen/xen_platform.c | 12 +++--- hw/isa/lpc_ich9.c | 10 ++--- hw/net/vmxnet3.c | 2 +- hw/pci-bridge/pci_expander_bridge.c | 17 +++++---- hw/pci-host/piix.c | 10 ++--- hw/pci-host/versatile.c | 2 +- hw/pci/pci.c | 76 +++++++++++++++++++--------------= ---- hw/pci/pci_bridge.c | 6 +-- hw/pci/pcie.c | 5 ++- hw/pci/pcie_aer.c | 2 +- hw/ppc/spapr_pci.c | 2 +- hw/s390x/s390-pci-bus.c | 8 ++-- hw/scsi/vmw_pvscsi.c | 2 +- hw/usb/hcd-xhci.c | 2 +- hw/vfio/pci.c | 10 ++--- hw/virtio/virtio-pci.c | 4 +- hw/xen/xen_pt.c | 4 +- 20 files changed, 102 insertions(+), 92 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index e451235..597ffb7 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -285,7 +285,6 @@ struct PCIDevice { uint8_t *used; =20 /* the following fields are read only */ - PCIBus *bus; int32_t devfn; /* Cached device to fetch requester ID from, to avoid the PCI * tree walking every time we invoke PCI request (e.g., @@ -435,10 +434,14 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *r= ootbus, =20 PCIDevice *pci_vga_init(PCIBus *bus); =20 +static inline PCIBus *pci_get_bus(const PCIDevice *dev) +{ + return PCI_BUS(qdev_get_parent_bus(DEVICE(dev))); +} int pci_bus_num(PCIBus *s); static inline int pci_dev_bus_num(const PCIDevice *dev) { - return pci_bus_num(dev->bus); + return pci_bus_num(pci_get_bus(dev)); } =20 int pci_bus_numa_node(PCIBus *bus); @@ -745,7 +748,7 @@ static inline uint32_t pci_config_size(const PCIDevice = *d) =20 static inline uint16_t pci_get_bdf(PCIDevice *dev) { - return PCI_BUILD_BDF(pci_bus_num(dev->bus), dev->devfn); + return PCI_BUILD_BDF(pci_bus_num(pci_get_bus(dev)), dev->devfn); } =20 uint16_t pci_requester_id(PCIDevice *dev); diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 7da51c0..91c82fd 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -223,7 +223,7 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_= dev, AcpiPciHpState *s, { PCIDevice *pdev =3D PCI_DEVICE(dev); int slot =3D PCI_SLOT(pdev->devfn); - int bsel =3D acpi_pcihp_get_bsel(pdev->bus); + int bsel =3D acpi_pcihp_get_bsel(pci_get_bus(pdev)); if (bsel < 0) { error_setg(errp, "Unsupported bus. Bus doesn't have property '" ACPI_PCIHP_PROP_BSEL "' set"); @@ -246,7 +246,7 @@ void acpi_pcihp_device_unplug_cb(HotplugHandler *hotplu= g_dev, AcpiPciHpState *s, { PCIDevice *pdev =3D PCI_DEVICE(dev); int slot =3D PCI_SLOT(pdev->devfn); - int bsel =3D acpi_pcihp_get_bsel(pdev->bus); + int bsel =3D acpi_pcihp_get_bsel(pci_get_bus(pdev)); if (bsel < 0) { error_setg(errp, "Unsupported bus. Bus doesn't have property '" ACPI_PCIHP_PROP_BSEL "' set"); diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index a0fb1ce..8b70345 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -460,9 +460,9 @@ static void piix4_pm_machine_ready(Notifier *n, void *o= paque) (memory_region_present(io_as, 0x2f8) ? 0x90 : 0); =20 if (s->use_acpi_pci_hotplug) { - pci_for_each_bus(d->bus, piix4_update_bus_hotplug, s); + pci_for_each_bus(pci_get_bus(d), piix4_update_bus_hotplug, s); } else { - piix4_update_bus_hotplug(d->bus, s); + piix4_update_bus_hotplug(pci_get_bus(d), s); } } =20 @@ -535,7 +535,8 @@ static void piix4_pm_realize(PCIDevice *dev, Error **er= rp) qemu_add_machine_init_done_notifier(&s->machine_ready); qemu_register_reset(piix4_reset, s); =20 - piix4_acpi_system_hot_add_init(pci_address_space_io(dev), dev->bus, s); + piix4_acpi_system_hot_add_init(pci_address_space_io(dev), + pci_get_bus(dev), s); =20 piix4_pm_add_propeties(s); } diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c index 056b87d..9ab5483 100644 --- a/hw/i386/xen/xen_platform.c +++ b/hw/i386/xen/xen_platform.c @@ -186,11 +186,11 @@ static void platform_fixed_ioport_writew(void *opaque= , uint32_t addr, uint32_t v if (val & (UNPLUG_IDE_SCSI_DISKS | UNPLUG_AUX_IDE_DISKS | UNPLUG_NVME_DISKS)) { DPRINTF("unplug disks\n"); - pci_unplug_disks(pci_dev->bus, val); + pci_unplug_disks(pci_get_bus(pci_dev), val); } if (val & UNPLUG_ALL_NICS) { DPRINTF("unplug nics\n"); - pci_unplug_nics(pci_dev->bus); + pci_unplug_nics(pci_get_bus(pci_dev)); } break; } @@ -372,17 +372,17 @@ static void xen_platform_ioport_writeb(void *opaque, = hwaddr addr, * If VMDP was to control both disk and LAN it would use 4. * If it controlled just disk or just LAN, it would use 8 belo= w. */ - pci_unplug_disks(pci_dev->bus, UNPLUG_IDE_SCSI_DISKS); - pci_unplug_nics(pci_dev->bus); + pci_unplug_disks(pci_get_bus(pci_dev), UNPLUG_IDE_SCSI_DISKS); + pci_unplug_nics(pci_get_bus(pci_dev)); } break; case 8: switch (val) { case 1: - pci_unplug_disks(pci_dev->bus, UNPLUG_IDE_SCSI_DISKS); + pci_unplug_disks(pci_get_bus(pci_dev), UNPLUG_IDE_SCSI_DISKS); break; case 2: - pci_unplug_nics(pci_dev->bus); + pci_unplug_nics(pci_get_bus(pci_dev)); break; default: log_writeb(s, (uint32_t)val); diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c index ec3c9f7..adcf077 100644 --- a/hw/isa/lpc_ich9.c +++ b/hw/isa/lpc_ich9.c @@ -162,7 +162,7 @@ static void ich9_cc_write(void *opaque, hwaddr addr, =20 ich9_cc_addr_len(&addr, &len); memcpy(lpc->chip_config + addr, &val, len); - pci_bus_fire_intx_routing_notifier(lpc->d.bus); + pci_bus_fire_intx_routing_notifier(pci_get_bus(&lpc->d)); ich9_cc_update(lpc); } =20 @@ -218,7 +218,7 @@ static void ich9_lpc_update_pic(ICH9LPCState *lpc, int = gsi) int tmp_dis; ich9_lpc_pic_irq(lpc, i, &tmp_irq, &tmp_dis); if (!tmp_dis && tmp_irq =3D=3D gsi) { - pic_level |=3D pci_bus_get_irq_level(lpc->d.bus, i); + pic_level |=3D pci_bus_get_irq_level(pci_get_bus(&lpc->d), i); } } if (gsi =3D=3D lpc->sci_gsi) { @@ -246,7 +246,7 @@ static void ich9_lpc_update_apic(ICH9LPCState *lpc, int= gsi) =20 assert(gsi >=3D ICH9_LPC_PIC_NUM_PINS); =20 - level |=3D pci_bus_get_irq_level(lpc->d.bus, ich9_gsi_to_pirq(gsi)); + level |=3D pci_bus_get_irq_level(pci_get_bus(&lpc->d), ich9_gsi_to_pir= q(gsi)); if (gsi =3D=3D lpc->sci_gsi) { level |=3D lpc->sci_level; } @@ -524,10 +524,10 @@ static void ich9_lpc_config_write(PCIDevice *d, ich9_lpc_rcba_update(lpc, rcba_old); } if (ranges_overlap(addr, len, ICH9_LPC_PIRQA_ROUT, 4)) { - pci_bus_fire_intx_routing_notifier(lpc->d.bus); + pci_bus_fire_intx_routing_notifier(pci_get_bus(&lpc->d)); } if (ranges_overlap(addr, len, ICH9_LPC_PIRQE_ROUT, 4)) { - pci_bus_fire_intx_routing_notifier(lpc->d.bus); + pci_bus_fire_intx_routing_notifier(pci_get_bus(&lpc->d)); } if (ranges_overlap(addr, len, ICH9_LPC_GEN_PMCON_1, 8)) { ich9_lpc_pmcon_update(lpc); diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index b8404cb..0654d59 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -2356,7 +2356,7 @@ static void vmxnet3_pci_realize(PCIDevice *pci_dev, E= rror **errp) vmxnet3_net_init(s); =20 if (pci_is_express(pci_dev)) { - if (pci_bus_is_express(pci_dev->bus)) { + if (pci_bus_is_express(pci_get_bus(pci_dev))) { pcie_endpoint_cap_init(pci_dev, VMXNET3_EXP_EP_OFFSET); } =20 diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expand= er_bridge.c index b2fa829..2a81eec 100644 --- a/hw/pci-bridge/pci_expander_bridge.c +++ b/hw/pci-bridge/pci_expander_bridge.c @@ -52,7 +52,8 @@ typedef struct PXBDev { =20 static PXBDev *convert_to_pxb(PCIDevice *dev) { - return pci_bus_is_express(dev->bus) ? PXB_PCIE_DEV(dev) : PXB_DEV(dev); + return pci_bus_is_express(pci_get_bus(dev)) + ? PXB_PCIE_DEV(dev) : PXB_DEV(dev); } =20 static GList *pxb_dev_list; @@ -166,7 +167,7 @@ static const TypeInfo pxb_host_info =3D { */ static void pxb_register_bus(PCIDevice *dev, PCIBus *pxb_bus, Error **errp) { - PCIBus *bus =3D dev->bus; + PCIBus *bus =3D pci_get_bus(dev); int pxb_bus_num =3D pci_bus_num(pxb_bus); =20 if (bus->parent_dev) { @@ -180,12 +181,12 @@ static void pxb_register_bus(PCIDevice *dev, PCIBus *= pxb_bus, Error **errp) return; } } - QLIST_INSERT_HEAD(&dev->bus->child, pxb_bus, sibling); + QLIST_INSERT_HEAD(&pci_get_bus(dev)->child, pxb_bus, sibling); } =20 static int pxb_map_irq_fn(PCIDevice *pci_dev, int pin) { - PCIDevice *pxb =3D pci_dev->bus->parent_dev; + PCIDevice *pxb =3D pci_get_bus(pci_dev)->parent_dev; =20 /* * The bios does not index the pxb slot number when @@ -240,8 +241,8 @@ static void pxb_dev_realize_common(PCIDevice *dev, bool= pcie, Error **errp) } =20 bus->parent_dev =3D dev; - bus->address_space_mem =3D dev->bus->address_space_mem; - bus->address_space_io =3D dev->bus->address_space_io; + bus->address_space_mem =3D pci_get_bus(dev)->address_space_mem; + bus->address_space_io =3D pci_get_bus(dev)->address_space_io; bus->map_irq =3D pxb_map_irq_fn; =20 PCI_HOST_BRIDGE(ds)->bus =3D bus; @@ -272,7 +273,7 @@ err_register_bus: =20 static void pxb_dev_realize(PCIDevice *dev, Error **errp) { - if (pci_bus_is_express(dev->bus)) { + if (pci_bus_is_express(pci_get_bus(dev))) { error_setg(errp, "pxb devices cannot reside on a PCIe bus"); return; } @@ -324,7 +325,7 @@ static const TypeInfo pxb_dev_info =3D { =20 static void pxb_pcie_dev_realize(PCIDevice *dev, Error **errp) { - if (!pci_bus_is_express(dev->bus)) { + if (!pci_bus_is_express(pci_get_bus(dev))) { error_setg(errp, "pxb-pcie devices cannot reside on a PCI bus"); return; } diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c index cf90701..effe3db 100644 --- a/hw/pci-host/piix.c +++ b/hw/pci-host/piix.c @@ -512,12 +512,12 @@ static PCIINTxRoute piix3_route_intx_pin_to_irq(void = *opaque, int pin) /* irq routing is changed. so rebuild bitmap */ static void piix3_update_irq_levels(PIIX3State *piix3) { + PCIBus *bus =3D pci_get_bus(&piix3->dev); int pirq; =20 piix3->pic_levels =3D 0; for (pirq =3D 0; pirq < PIIX_NUM_PIRQS; pirq++) { - piix3_set_irq_level(piix3, pirq, - pci_bus_get_irq_level(piix3->dev.bus, pirq)); + piix3_set_irq_level(piix3, pirq, pci_bus_get_irq_level(bus, pirq)); } } =20 @@ -529,7 +529,7 @@ static void piix3_write_config(PCIDevice *dev, PIIX3State *piix3 =3D PIIX3_PCI_DEVICE(dev); int pic_irq; =20 - pci_bus_fire_intx_routing_notifier(piix3->dev.bus); + pci_bus_fire_intx_routing_notifier(pci_get_bus(&piix3->dev)); piix3_update_irq_levels(piix3); for (pic_irq =3D 0; pic_irq < PIIX_NUM_PIC_IRQS; pic_irq++) { piix3_set_irq_pic(piix3, pic_irq); @@ -601,7 +601,7 @@ static int piix3_post_load(void *opaque, int version_id) piix3->pic_levels =3D 0; for (pirq =3D 0; pirq < PIIX_NUM_PIRQS; pirq++) { piix3_set_irq_level_internal(piix3, pirq, - pci_bus_get_irq_level(piix3->dev.bus, pirq)); + pci_bus_get_irq_level(pci_get_bus(&piix3->dev), pirq)); } return 0; } @@ -613,7 +613,7 @@ static int piix3_pre_save(void *opaque) =20 for (i =3D 0; i < ARRAY_SIZE(piix3->pci_irq_levels_vmstate); i++) { piix3->pci_irq_levels_vmstate[i] =3D - pci_bus_get_irq_level(piix3->dev.bus, i); + pci_bus_get_irq_level(pci_get_bus(&piix3->dev), i); } =20 return 0; diff --git a/hw/pci-host/versatile.c b/hw/pci-host/versatile.c index 8803ada..d0b02bd 100644 --- a/hw/pci-host/versatile.c +++ b/hw/pci-host/versatile.c @@ -311,7 +311,7 @@ static const MemoryRegionOps pci_vpb_config_ops =3D { =20 static int pci_vpb_map_irq(PCIDevice *d, int irq_num) { - PCIVPBState *s =3D container_of(d->bus, PCIVPBState, pci_bus); + PCIVPBState *s =3D container_of(pci_get_bus(d), PCIVPBState, pci_bus); =20 if (s->irq_mapping =3D=3D PCI_VPB_IRQMAP_BROKEN) { /* Legacy broken IRQ mapping for compatibility with old and diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 232e7da..567be1b 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -222,7 +222,7 @@ static void pci_change_irq_level(PCIDevice *pci_dev, in= t irq_num, int change) { PCIBus *bus; for (;;) { - bus =3D pci_dev->bus; + bus =3D pci_get_bus(pci_dev); irq_num =3D bus->map_irq(pci_dev, irq_num); if (bus->set_irq) break; @@ -349,13 +349,13 @@ PCIBus *pci_find_primary_bus(void) =20 PCIBus *pci_device_root_bus(const PCIDevice *d) { - PCIBus *bus =3D d->bus; + PCIBus *bus =3D pci_get_bus(d); =20 while (!pci_bus_is_root(bus)) { d =3D bus->parent_dev; assert(d !=3D NULL); =20 - bus =3D d->bus; + bus =3D pci_get_bus(d); } =20 return bus; @@ -882,7 +882,7 @@ static void pci_config_free(PCIDevice *pci_dev) =20 static void do_pci_unregister_device(PCIDevice *pci_dev) { - pci_dev->bus->devices[pci_dev->devfn] =3D NULL; + pci_get_bus(pci_dev)->devices[pci_dev->devfn] =3D NULL; pci_config_free(pci_dev); =20 if (memory_region_is_mapped(&pci_dev->bus_master_enable_region)) { @@ -903,7 +903,7 @@ static uint16_t pci_req_id_cache_extract(PCIReqIDCache = *cache) result =3D pci_get_bdf(cache->dev); break; case PCI_REQ_ID_SECONDARY_BUS: - bus_n =3D pci_bus_num(cache->dev->bus); + bus_n =3D pci_dev_bus_num(cache->dev); result =3D PCI_BUILD_BDF(bus_n, 0); break; default: @@ -933,9 +933,9 @@ static PCIReqIDCache pci_req_id_cache_get(PCIDevice *de= v) .type =3D PCI_REQ_ID_BDF, }; =20 - while (!pci_bus_is_root(dev->bus)) { + while (!pci_bus_is_root(pci_get_bus(dev))) { /* We are under PCI/PCIe bridges */ - parent =3D dev->bus->parent_dev; + parent =3D pci_get_bus(dev)->parent_dev; if (pci_is_express(parent)) { if (pcie_cap_get_type(parent) =3D=3D PCI_EXP_TYPE_PCI_BRIDGE) { /* When we pass through PCIe-to-PCI/PCIX bridges, we @@ -978,7 +978,7 @@ static bool pci_bus_devfn_reserved(PCIBus *bus, int dev= fn) } =20 /* -1 for devfn means auto assign */ -static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, +static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, const char *name, int devfn, Error **errp) { @@ -987,8 +987,8 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci= _dev, PCIBus *bus, PCIConfigWriteFunc *config_write =3D pc->config_write; Error *local_err =3D NULL; DeviceState *dev =3D DEVICE(pci_dev); + PCIBus *bus =3D pci_get_bus(pci_dev); =20 - pci_dev->bus =3D bus; /* Only pci bridges can be attached to extra PCI root buses */ if (pci_bus_is_root(bus) && bus->parent_dev && !pc->is_bridge) { error_setg(errp, @@ -1142,8 +1142,8 @@ void pci_register_bar(PCIDevice *pci_dev, int region_= num, r->type =3D type; r->memory =3D memory; r->address_space =3D type & PCI_BASE_ADDRESS_SPACE_IO - ? pci_dev->bus->address_space_io - : pci_dev->bus->address_space_mem; + ? pci_get_bus(pci_dev)->address_space_io + : pci_get_bus(pci_dev)->address_space_mem; =20 wmask =3D ~(size - 1); if (region_num =3D=3D PCI_ROM_SLOT) { @@ -1185,21 +1185,23 @@ static void pci_update_vga(PCIDevice *pci_dev) void pci_register_vga(PCIDevice *pci_dev, MemoryRegion *mem, MemoryRegion *io_lo, MemoryRegion *io_hi) { + PCIBus *bus =3D pci_get_bus(pci_dev); + assert(!pci_dev->has_vga); =20 assert(memory_region_size(mem) =3D=3D QEMU_PCI_VGA_MEM_SIZE); pci_dev->vga_regions[QEMU_PCI_VGA_MEM] =3D mem; - memory_region_add_subregion_overlap(pci_dev->bus->address_space_mem, + memory_region_add_subregion_overlap(bus->address_space_mem, QEMU_PCI_VGA_MEM_BASE, mem, 1); =20 assert(memory_region_size(io_lo) =3D=3D QEMU_PCI_VGA_IO_LO_SIZE); pci_dev->vga_regions[QEMU_PCI_VGA_IO_LO] =3D io_lo; - memory_region_add_subregion_overlap(pci_dev->bus->address_space_io, + memory_region_add_subregion_overlap(bus->address_space_io, QEMU_PCI_VGA_IO_LO_BASE, io_lo, 1); =20 assert(memory_region_size(io_hi) =3D=3D QEMU_PCI_VGA_IO_HI_SIZE); pci_dev->vga_regions[QEMU_PCI_VGA_IO_HI] =3D io_hi; - memory_region_add_subregion_overlap(pci_dev->bus->address_space_io, + memory_region_add_subregion_overlap(bus->address_space_io, QEMU_PCI_VGA_IO_HI_BASE, io_hi, 1); pci_dev->has_vga =3D true; =20 @@ -1208,15 +1210,17 @@ void pci_register_vga(PCIDevice *pci_dev, MemoryReg= ion *mem, =20 void pci_unregister_vga(PCIDevice *pci_dev) { + PCIBus *bus =3D pci_get_bus(pci_dev); + if (!pci_dev->has_vga) { return; } =20 - memory_region_del_subregion(pci_dev->bus->address_space_mem, + memory_region_del_subregion(bus->address_space_mem, pci_dev->vga_regions[QEMU_PCI_VGA_MEM]); - memory_region_del_subregion(pci_dev->bus->address_space_io, + memory_region_del_subregion(bus->address_space_io, pci_dev->vga_regions[QEMU_PCI_VGA_IO_LO]); - memory_region_del_subregion(pci_dev->bus->address_space_io, + memory_region_del_subregion(bus->address_space_io, pci_dev->vga_regions[QEMU_PCI_VGA_IO_HI]); pci_dev->has_vga =3D false; } @@ -1319,7 +1323,7 @@ static void pci_update_mappings(PCIDevice *d) =20 /* now do the real mapping */ if (r->addr !=3D PCI_BAR_UNMAPPED) { - trace_pci_update_mappings_del(d, pci_bus_num(d->bus), + trace_pci_update_mappings_del(d, pci_dev_bus_num(d), PCI_SLOT(d->devfn), PCI_FUNC(d->devfn), i, r->addr, r->size); @@ -1327,7 +1331,7 @@ static void pci_update_mappings(PCIDevice *d) } r->addr =3D new_addr; if (r->addr !=3D PCI_BAR_UNMAPPED) { - trace_pci_update_mappings_add(d, pci_bus_num(d->bus), + trace_pci_update_mappings_add(d, pci_dev_bus_num(d), PCI_SLOT(d->devfn), PCI_FUNC(d->devfn), i, r->addr, r->size); @@ -1446,9 +1450,9 @@ PCIINTxRoute pci_device_route_intx_to_irq(PCIDevice *= dev, int pin) PCIBus *bus; =20 do { - bus =3D dev->bus; - pin =3D bus->map_irq(dev, pin); - dev =3D bus->parent_dev; + bus =3D pci_get_bus(dev); + pin =3D bus->map_irq(dev, pin); + dev =3D bus->parent_dev; } while (dev); =20 if (!bus->route_intx_to_irq) { @@ -2018,7 +2022,6 @@ static void pci_qdev_realize(DeviceState *qdev, Error= **errp) PCIDevice *pci_dev =3D (PCIDevice *)qdev; PCIDeviceClass *pc =3D PCI_DEVICE_GET_CLASS(pci_dev); Error *local_err =3D NULL; - PCIBus *bus; bool is_default_rom; =20 /* initialize cap_present for pci_is_express() and pci_config_size() */ @@ -2026,8 +2029,7 @@ static void pci_qdev_realize(DeviceState *qdev, Error= **errp) pci_dev->cap_present |=3D QEMU_PCI_CAP_EXPRESS; } =20 - bus =3D PCI_BUS(qdev_get_parent_bus(qdev)); - pci_dev =3D do_pci_register_device(pci_dev, bus, + pci_dev =3D do_pci_register_device(pci_dev, object_get_typename(OBJECT(qdev)), pci_dev->devfn, errp); if (pci_dev =3D=3D NULL) @@ -2320,7 +2322,7 @@ int pci_add_capability(PCIDevice *pdev, uint8_t cap_i= d, error_setg(errp, "%s:%02x:%02x.%x " "Attempt to add PCI capability %x at offset " "%x overlaps existing capability %x at offset %= x", - pci_root_bus_path(pdev), pci_bus_num(pdev->bus), + pci_root_bus_path(pdev), pci_dev_bus_num(pdev), PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), cap_id, offset, overlapping_cap, i); return -EINVAL; @@ -2384,7 +2386,7 @@ static void pcibus_dev_print(Monitor *mon, DeviceStat= e *dev, int indent) =20 monitor_printf(mon, "%*sclass %s, addr %02x:%02x.%x, " "pci id %04x:%04x (sub %04x:%04x)\n", - indent, "", ctxt, pci_bus_num(d->bus), + indent, "", ctxt, pci_dev_bus_num(d), PCI_SLOT(d->devfn), PCI_FUNC(d->devfn), pci_get_word(d->config + PCI_VENDOR_ID), pci_get_word(d->config + PCI_DEVICE_ID), @@ -2467,7 +2469,7 @@ static char *pcibus_get_dev_path(DeviceState *dev) =20 /* Calculate # of slots on path between device and root. */; slot_depth =3D 0; - for (t =3D d; t; t =3D t->bus->parent_dev) { + for (t =3D d; t; t =3D pci_get_bus(t)->parent_dev) { ++slot_depth; } =20 @@ -2482,7 +2484,7 @@ static char *pcibus_get_dev_path(DeviceState *dev) /* Fill in slot numbers. We walk up from device to root, so need to pr= int * them in the reverse order, last to first. */ p =3D path + path_len; - for (t =3D d; t; t =3D t->bus->parent_dev) { + for (t =3D d; t; t =3D pci_get_bus(t)->parent_dev) { p -=3D slot_len; s =3D snprintf(slot, sizeof slot, ":%02x.%x", PCI_SLOT(t->devfn), PCI_FUNC(t->devfn)); @@ -2530,12 +2532,12 @@ int pci_qdev_find_device(const char *id, PCIDevice = **pdev) =20 MemoryRegion *pci_address_space(PCIDevice *dev) { - return dev->bus->address_space_mem; + return pci_get_bus(dev)->address_space_mem; } =20 MemoryRegion *pci_address_space_io(PCIDevice *dev) { - return dev->bus->address_space_io; + return pci_get_bus(dev)->address_space_io; } =20 static void pci_device_class_init(ObjectClass *klass, void *data) @@ -2563,11 +2565,11 @@ static void pci_device_class_base_init(ObjectClass = *klass, void *data) =20 AddressSpace *pci_device_iommu_address_space(PCIDevice *dev) { - PCIBus *bus =3D PCI_BUS(dev->bus); + PCIBus *bus =3D pci_get_bus(dev); PCIBus *iommu_bus =3D bus; =20 while(iommu_bus && !iommu_bus->iommu_fn && iommu_bus->parent_dev) { - iommu_bus =3D PCI_BUS(iommu_bus->parent_dev->bus); + iommu_bus =3D pci_get_bus(iommu_bus->parent_dev); } if (iommu_bus && iommu_bus->iommu_fn) { return iommu_bus->iommu_fn(bus, iommu_bus->iommu_opaque, dev->devf= n); @@ -2638,7 +2640,7 @@ void pci_bus_get_w64_range(PCIBus *bus, Range *range) =20 static bool pcie_has_upstream_port(PCIDevice *dev) { - PCIDevice *parent_dev =3D pci_bridge_get_device(dev->bus); + PCIDevice *parent_dev =3D pci_bridge_get_device(pci_get_bus(dev)); =20 /* Device associated with an upstream port. * As there are several types of these, it's easier to check the @@ -2654,12 +2656,14 @@ static bool pcie_has_upstream_port(PCIDevice *dev) =20 PCIDevice *pci_get_function_0(PCIDevice *pci_dev) { + PCIBus *bus =3D pci_get_bus(pci_dev); + if(pcie_has_upstream_port(pci_dev)) { /* With an upstream PCIe port, we only support 1 device at slot 0 = */ - return pci_dev->bus->devices[0]; + return bus->devices[0]; } else { /* Other bus types might support multiple devices at slots 0-31 */ - return pci_dev->bus->devices[PCI_DEVFN(PCI_SLOT(pci_dev->devfn), 0= )]; + return bus->devices[PCI_DEVFN(PCI_SLOT(pci_dev->devfn), 0)]; } } =20 diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c index a47d257..b2e50c3 100644 --- a/hw/pci/pci_bridge.c +++ b/hw/pci/pci_bridge.c @@ -183,7 +183,7 @@ static void pci_bridge_init_vga_aliases(PCIBridge *br, = PCIBus *parent, static PCIBridgeWindows *pci_bridge_region_init(PCIBridge *br) { PCIDevice *pd =3D PCI_DEVICE(br); - PCIBus *parent =3D pd->bus; + PCIBus *parent =3D pci_get_bus(pd); PCIBridgeWindows *w =3D g_new(PCIBridgeWindows, 1); uint16_t cmd =3D pci_get_word(pd->config + PCI_COMMAND); =20 @@ -214,7 +214,7 @@ static PCIBridgeWindows *pci_bridge_region_init(PCIBrid= ge *br) static void pci_bridge_region_del(PCIBridge *br, PCIBridgeWindows *w) { PCIDevice *pd =3D PCI_DEVICE(br); - PCIBus *parent =3D pd->bus; + PCIBus *parent =3D pci_get_bus(pd); =20 memory_region_del_subregion(parent->address_space_io, &w->alias_io); memory_region_del_subregion(parent->address_space_mem, &w->alias_mem); @@ -339,7 +339,7 @@ void pci_bridge_reset(DeviceState *qdev) /* default qdev initialization function for PCI-to-PCI bridge */ void pci_bridge_initfn(PCIDevice *dev, const char *typename) { - PCIBus *parent =3D dev->bus; + PCIBus *parent =3D pci_get_bus(dev); PCIBridge *br =3D PCI_BRIDGE(dev); PCIBus *sec_bus =3D &br->sec_bus; =20 diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 32191f2..6c91bd4 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -155,7 +155,8 @@ pcie_endpoint_cap_common_init(PCIDevice *dev, uint8_t o= ffset, uint8_t cap_size) * a regular Endpoint type is exposed on a root complex. These * should instead be Root Complex Integrated Endpoints. */ - if (pci_bus_is_express(dev->bus) && pci_bus_is_root(dev->bus)) { + if (pci_bus_is_express(pci_get_bus(dev)) + && pci_bus_is_root(pci_get_bus(dev))) { type =3D PCI_EXP_TYPE_RC_END; } =20 @@ -369,7 +370,7 @@ void pcie_cap_slot_hot_unplug_request_cb(HotplugHandler= *hotplug_dev, { uint8_t *exp_cap; PCIDevice *pci_dev =3D PCI_DEVICE(dev); - PCIBus *bus =3D pci_dev->bus; + PCIBus *bus =3D pci_get_bus(pci_dev); =20 pcie_cap_slot_hotplug_common(PCI_DEVICE(hotplug_dev), dev, &exp_cap, e= rrp); =20 diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c index 21f896a..b009be7 100644 --- a/hw/pci/pcie_aer.c +++ b/hw/pci/pcie_aer.c @@ -409,7 +409,7 @@ static void pcie_aer_msg(PCIDevice *dev, const PCIEAERM= sg *msg) */ return; } - dev =3D pci_bridge_get_device(dev->bus); + dev =3D pci_bridge_get_device(pci_get_bus(dev)); } } =20 diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 9262682..f38be2f 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -505,7 +505,7 @@ static void rtas_ibm_get_config_addr_info2(PowerPCCPU *= cpu, goto param_error_exit; } =20 - rtas_st(rets, 1, (pci_bus_num(pdev->bus) << 16) + 1); + rtas_st(rets, 1, (pci_bus_num(pci_get_bus(pdev)) << 16) + 1); break; case RTAS_GET_PE_MODE: rtas_st(rets, 1, RTAS_PE_MODE_SHARED); diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index f64ad59..7d9c65e 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -680,10 +680,10 @@ static void s390_pcihost_hot_plug(HotplugHandler *hot= plug_dev, s->bus_no +=3D 1; pci_default_write_config(pdev, PCI_SECONDARY_BUS, s->bus_no, 1= ); do { - pdev =3D pdev->bus->parent_dev; + pdev =3D pci_get_bus(pdev)->parent_dev; pci_default_write_config(pdev, PCI_SUBORDINATE_BUS, s->bus_no, 1); - } while (pdev->bus && pci_bus_num(pdev->bus)); + } while (pci_get_bus(pdev) && pci_dev_bus_num(pdev)); } } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { pdev =3D PCI_DEVICE(dev); @@ -713,7 +713,7 @@ static void s390_pcihost_hot_plug(HotplugHandler *hotpl= ug_dev, } =20 pbdev->pdev =3D pdev; - pbdev->iommu =3D s390_pci_get_iommu(s, pdev->bus, pdev->devfn); + pbdev->iommu =3D s390_pci_get_iommu(s, pci_get_bus(pdev), pdev->de= vfn); pbdev->iommu->pbdev =3D pbdev; pbdev->state =3D ZPCI_FS_DISABLED; =20 @@ -807,7 +807,7 @@ static void s390_pcihost_hot_unplug(HotplugHandler *hot= plug_dev, =20 s390_pci_generate_plug_event(HP_EVENT_STANDBY_TO_RESERVED, pbdev->fh, pbdev->fid); - bus =3D pci_dev->bus; + bus =3D pci_get_bus(pci_dev); devfn =3D pci_dev->devfn; object_unparent(OBJECT(pci_dev)); s390_pci_msix_free(pbdev); diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c index d564e5c..27749c0 100644 --- a/hw/scsi/vmw_pvscsi.c +++ b/hw/scsi/vmw_pvscsi.c @@ -1133,7 +1133,7 @@ pvscsi_realizefn(PCIDevice *pci_dev, Error **errp) =20 pvscsi_init_msi(s); =20 - if (pci_is_express(pci_dev) && pci_bus_is_express(pci_dev->bus)) { + if (pci_is_express(pci_dev) && pci_bus_is_express(pci_get_bus(pci_dev)= )) { pcie_endpoint_cap_init(pci_dev, PVSCSI_EXP_EP_OFFSET); } =20 diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index af3a9d8..228e82b 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -3416,7 +3416,7 @@ static void usb_xhci_realize(struct PCIDevice *dev, E= rror **errp) PCI_BASE_ADDRESS_SPACE_MEMORY|PCI_BASE_ADDRESS_MEM_TY= PE_64, &xhci->mem); =20 - if (pci_bus_is_express(dev->bus) || + if (pci_bus_is_express(pci_get_bus(dev)) || xhci_get_flag(xhci, XHCI_FLAG_FORCE_PCIE_ENDCAP)) { ret =3D pcie_endpoint_cap_init(dev, 0xa0); assert(ret > 0); diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index c977ee3..2c71295 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -1654,8 +1654,8 @@ static int vfio_setup_pcie_cap(VFIOPCIDevice *vdev, i= nt pos, uint8_t size, return -EINVAL; } =20 - if (!pci_bus_is_express(vdev->pdev.bus)) { - PCIBus *bus =3D vdev->pdev.bus; + if (!pci_bus_is_express(pci_get_bus(&vdev->pdev))) { + PCIBus *bus =3D pci_get_bus(&vdev->pdev); PCIDevice *bridge; =20 /* @@ -1680,14 +1680,14 @@ static int vfio_setup_pcie_cap(VFIOPCIDevice *vdev,= int pos, uint8_t size, */ while (!pci_bus_is_root(bus)) { bridge =3D pci_bridge_get_device(bus); - bus =3D bridge->bus; + bus =3D pci_get_bus(bridge); } =20 if (pci_bus_is_express(bus)) { return 0; } =20 - } else if (pci_bus_is_root(vdev->pdev.bus)) { + } else if (pci_bus_is_root(pci_get_bus(&vdev->pdev))) { /* * On a Root Complex bus Endpoints become Root Complex Integrated * Endpoints, which changes the type and clears the LNK & LNK2 fie= lds. @@ -1890,7 +1890,7 @@ static void vfio_add_ext_cap(VFIOPCIDevice *vdev) uint8_t *config; =20 /* Only add extended caps if we have them and the guest can see them */ - if (!pci_is_express(pdev) || !pci_bus_is_express(pdev->bus) || + if (!pci_is_express(pdev) || !pci_bus_is_express(pci_get_bus(pdev)) || !pci_get_long(pdev->config + PCI_CONFIG_SPACE_SIZE)) { return; } diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index e92837c..42b31fb 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1708,8 +1708,8 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Er= ror **errp) { VirtIOPCIProxy *proxy =3D VIRTIO_PCI(pci_dev); VirtioPCIClass *k =3D VIRTIO_PCI_GET_CLASS(pci_dev); - bool pcie_port =3D pci_bus_is_express(pci_dev->bus) && - !pci_bus_is_root(pci_dev->bus); + bool pcie_port =3D pci_bus_is_express(pci_get_bus(pci_dev)) && + !pci_bus_is_root(pci_get_bus(pci_dev)); =20 if (kvm_enabled() && !kvm_has_many_ioeventfds()) { proxy->flags &=3D ~VIRTIO_PCI_FLAG_USE_IOEVENTFD; diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index 6236f0c..752b6f6 100644 --- a/hw/xen/xen_pt.c +++ b/hw/xen/xen_pt.c @@ -602,7 +602,7 @@ static void xen_pt_region_update(XenPCIPassthroughState= *s, } =20 args.type =3D d->io_regions[bar].type; - pci_for_each_device(d->bus, pci_bus_num(d->bus), + pci_for_each_device(pci_get_bus(d), pci_dev_bus_num(d), xen_pt_check_bar_overlap, &args); if (args.rc) { XEN_PT_WARN(d, "Region: %d (addr: %#"FMT_PCIBUS @@ -695,7 +695,7 @@ xen_igd_passthrough_isa_bridge_create(XenPCIPassthrough= State *s, PCIDevice *d =3D &s->dev; =20 gpu_dev_id =3D dev->device_id; - igd_passthrough_isa_bridge_create(d->bus, gpu_dev_id); + igd_passthrough_isa_bridge_create(pci_get_bus(d), gpu_dev_id); } =20 /* destroy. */ --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 151386719740489.34506358967485; Thu, 21 Dec 2017 06:39:57 -0800 (PST) Received: from localhost ([::1]:53128 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS20j-0007gd-8H for importer@patchew.org; Thu, 21 Dec 2017 09:39:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45742) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1qV-0007nH-CQ for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1qU-0005cT-J6 for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55130) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1qU-0005bp-B3 for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:14 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7A0CD4B92; Thu, 21 Dec 2017 14:29:13 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with SMTP id 0877A5C6D4; Thu, 21 Dec 2017 14:29:06 +0000 (UTC) Date: Thu, 21 Dec 2017 16:29:06 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-10-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 21 Dec 2017 14:29:13 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 09/25] pci: Eliminate pci_find_primary_bus() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Peter Xu , Marcel Apfelbaum , Paolo Bonzini , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Gibson pci_find_primary_bus() only has one user, in pc_xen_hvm_init(). That's inside the machine construction code, so it already has easy access to the machine's primary PCI bus. Get it directly, and thereby remove pci_find_primary_bus(). This removes one of only a handful of users of the ugly pci_host_bridges global. Signed-off-by: David Gibson Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Marcel Apfelbaum Reviewed-by: Peter Xu --- include/hw/pci/pci.h | 1 - hw/i386/pc_piix.c | 8 ++------ hw/pci/pci.c | 16 ---------------- 3 files changed, 2 insertions(+), 23 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 597ffb7..15ced96 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -467,7 +467,6 @@ void pci_for_each_bus(PCIBus *bus, pci_for_each_bus_depth_first(bus, NULL, fn, opaque); } =20 -PCIBus *pci_find_primary_bus(void); PCIBus *pci_device_root_bus(const PCIDevice *d); const char *pci_root_bus_path(PCIDevice *dev); PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn); diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 5e47528..2febd0e 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -394,7 +394,7 @@ static void pc_xen_hvm_init_pci(MachineState *machine) =20 static void pc_xen_hvm_init(MachineState *machine) { - PCIBus *bus; + PCMachineState *pcms =3D PC_MACHINE(machine); =20 if (!xen_enabled()) { error_report("xenfv machine requires the xen accelerator"); @@ -402,11 +402,7 @@ static void pc_xen_hvm_init(MachineState *machine) } =20 pc_xen_hvm_init_pci(machine); - - bus =3D pci_find_primary_bus(); - if (bus !=3D NULL) { - pci_create_simple(bus, -1, "xen-platform"); - } + pci_create_simple(pcms->bus, -1, "xen-platform"); } #endif =20 diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 567be1b..e8f9fc1 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -331,22 +331,6 @@ static void pci_host_bus_register(DeviceState *host) QLIST_INSERT_HEAD(&pci_host_bridges, host_bridge, next); } =20 -PCIBus *pci_find_primary_bus(void) -{ - PCIBus *primary_bus =3D NULL; - PCIHostState *host; - - QLIST_FOREACH(host, &pci_host_bridges, next) { - if (primary_bus) { - /* We have multiple root buses, refuse to select a primary */ - return NULL; - } - primary_bus =3D host->bus; - } - - return primary_bus; -} - PCIBus *pci_device_root_bus(const PCIDevice *d) { PCIBus *bus =3D pci_get_bus(d); --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513867381010735.5067873289328; Thu, 21 Dec 2017 06:43:01 -0800 (PST) Received: from localhost ([::1]:53175 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS23g-0001ok-V4 for importer@patchew.org; Thu, 21 Dec 2017 09:42:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45766) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1qW-0007oa-M3 for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1qV-0005dx-Lk for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48210) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1qV-0005cx-Fw; Thu, 21 Dec 2017 09:29:15 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A6E3121BA9; Thu, 21 Dec 2017 14:29:14 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with SMTP id 16B226363D; Thu, 21 Dec 2017 14:29:13 +0000 (UTC) Date: Thu, 21 Dec 2017 16:29:13 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-11-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 21 Dec 2017 14:29:14 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 10/25] virtio_error: don't invoke status callbacks X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ilya Maximets , Peter Maydell , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Backends don't need to know what frontend requested a reset, and notifying then from virtio_error is messy because virtio_error itself might be invoked from backend. Let's just set the status directly. Cc: qemu-stable@nongnu.org Reported-by: Ilya Maximets Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index ad564b0..d6002ee 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2469,7 +2469,7 @@ void GCC_FMT_ATTR(2, 3) virtio_error(VirtIODevice *vd= ev, const char *fmt, ...) va_end(ap); =20 if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { - virtio_set_status(vdev, vdev->status | VIRTIO_CONFIG_S_NEEDS_RESET= ); + vdev->status =3D vdev->status | VIRTIO_CONFIG_S_NEEDS_RESET; virtio_notify_config(vdev); } =20 --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513868134400630.2359644389601; Thu, 21 Dec 2017 06:55:34 -0800 (PST) Received: from localhost ([::1]:53369 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS2Fi-0003nA-7y for importer@patchew.org; Thu, 21 Dec 2017 09:55:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1qa-0007sM-H0 for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1qX-0005ey-32 for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56260) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1qW-0005eS-Sm for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:17 -0500 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 1721E61472; Thu, 21 Dec 2017 14:29:16 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with SMTP id 4986B60C8E; Thu, 21 Dec 2017 14:29:15 +0000 (UTC) Date: Thu, 21 Dec 2017 16:29:14 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-12-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent 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.39]); Thu, 21 Dec 2017 14:29:16 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 11/25] tests/pxe-test: Remove unnecessary special case test functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Cornelia Huck , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Gibson All of the x86 and some of the other test cases here use a common test function, test_pxe_ipv4(), but one ppc and one s390 test use different functions. In the s390 case, this is completely pointless, the right parameter to test_pxe_ipv4() will already do exactly the right thing. For the spapr-vlan case there's a slight difference - it will use IPv6 instead of IPv4. But testing just one case with IPv6 (and NOT IPv4) is rather haphazard. Change everything to use the common test function, until we have a better way of testing IPv6 across the board. Signed-off-by: David Gibson Reviewed-by: Thomas Huth Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/pxe-test.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/tests/pxe-test.c b/tests/pxe-test.c index 937f29e..eb70aa2 100644 --- a/tests/pxe-test.c +++ b/tests/pxe-test.c @@ -47,16 +47,6 @@ static void test_pxe_ipv4(gconstpointer data) g_free(dev_arg); } =20 -static void test_pxe_spapr_vlan(void) -{ - test_pxe_one("-device spapr-vlan,netdev=3D" NETNAME, true); -} - -static void test_pxe_virtio_ccw(void) -{ - test_pxe_one("-device virtio-net-ccw,bootindex=3D1,netdev=3D" NETNAME,= false); -} - int main(int argc, char *argv[]) { int ret; @@ -79,13 +69,14 @@ int main(int argc, char *argv[]) qtest_add_data_func("pxe/vmxnet3", "vmxnet3", test_pxe_ipv4); } } else if (strcmp(arch, "ppc64") =3D=3D 0) { - qtest_add_func("pxe/spapr-vlan", test_pxe_spapr_vlan); + qtest_add_data_func("pxe/spapr-vlan", "spapr-vlan", test_pxe_ipv4); if (g_test_slow()) { qtest_add_data_func("pxe/virtio", "virtio-net-pci", test_pxe_i= pv4); qtest_add_data_func("pxe/e1000", "e1000", test_pxe_ipv4); } } else if (g_str_equal(arch, "s390x")) { - qtest_add_func("pxe/virtio-ccw", test_pxe_virtio_ccw); + qtest_add_data_func("pxe/virtio-ccw", + "virtio-net-ccw,bootindex=3D1", test_pxe_ipv4); } ret =3D g_test_run(); boot_sector_cleanup(disk); --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513868494214490.0189059425303; Thu, 21 Dec 2017 07:01:34 -0800 (PST) Received: from localhost ([::1]:53476 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS2LQ-0000bq-2m for importer@patchew.org; Thu, 21 Dec 2017 10:01:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45874) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1qd-0007vD-8T for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1qZ-0005gX-6Y for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48270) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1qY-0005fz-Uc for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:19 -0500 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 2D27E3683C; Thu, 21 Dec 2017 14:29:18 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with SMTP id C1A415DA67; Thu, 21 Dec 2017 14:29:16 +0000 (UTC) Date: Thu, 21 Dec 2017 16:29:16 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-13-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent 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.30]); Thu, 21 Dec 2017 14:29:18 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 12/25] tests/pxe-test: Use table of testcases rather than open-coding X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Cornelia Huck , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Gibson Currently pxe-tests open codes the list of tests for each architecture. This changes it to use tables of test parameters, somewhat similar to boot-serial-test. This adds the machine type into the table as well, giving us the ability to perform tests on multiple machine types for architectures where there's more than one machine type that matters. NOTE: This changes the names of the tests in the output, to include the machine type and IPv4 vs. IPv6. I'm not sure if this has the potential to break existing tooling. Signed-off-by: David Gibson Reviewed-by: Thomas Huth Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/pxe-test.c | 86 +++++++++++++++++++++++++++++++++++++++++-----------= ---- 1 file changed, 64 insertions(+), 22 deletions(-) diff --git a/tests/pxe-test.c b/tests/pxe-test.c index eb70aa2..4758ce7 100644 --- a/tests/pxe-test.c +++ b/tests/pxe-test.c @@ -22,14 +22,51 @@ =20 static char disk[] =3D "tests/pxe-test-disk-XXXXXX"; =20 -static void test_pxe_one(const char *params, bool ipv6) +typedef struct testdef { + const char *machine; /* Machine type */ + const char *model; /* NIC device model */ +} testdef_t; + +static testdef_t x86_tests[] =3D { + { "pc", "e1000" }, + { "pc", "virtio-net-pci" }, + { NULL }, +}; + +static testdef_t x86_tests_slow[] =3D { + { "pc", "ne2k_pci", }, + { "pc", "i82550", }, + { "pc", "rtl8139" }, + { "pc", "vmxnet3" }, + { NULL }, +}; + +static testdef_t ppc64_tests[] =3D { + { "pseries", "spapr-vlan" }, + { NULL }, +}; + +static testdef_t ppc64_tests_slow[] =3D { + { "pseries", "virtio-net-pci", }, + { "pseries", "e1000" }, + { NULL }, +}; + +static testdef_t s390x_tests[] =3D { + { "s390-ccw-virtio", "virtio-net-ccw" }, + { NULL }, +}; + +static void test_pxe_one(const testdef_t *test, bool ipv6) { char *args; =20 - args =3D g_strdup_printf("-machine accel=3Dkvm:tcg -nodefaults -boot o= rder=3Dn " - "-netdev user,id=3D" NETNAME ",tftp=3D./,bootfi= le=3D%s," - "ipv4=3D%s,ipv6=3D%s %s", disk, ipv6 ? "off" : = "on", - ipv6 ? "on" : "off", params); + args =3D g_strdup_printf( + "-machine %s,accel=3Dkvm:tcg -nodefaults -boot order=3Dn " + "-netdev user,id=3D" NETNAME ",tftp=3D./,bootfile=3D%s,ipv4=3D%s,i= pv6=3D%s " + "-device %s,bootindex=3D1,netdev=3D" NETNAME, + test->machine, disk, ipv6 ? "off" : "on", ipv6 ? "on" : "off", + test->model); =20 qtest_start(args); boot_sector_test(); @@ -39,12 +76,24 @@ static void test_pxe_one(const char *params, bool ipv6) =20 static void test_pxe_ipv4(gconstpointer data) { - const char *model =3D data; - char *dev_arg; + const testdef_t *test =3D data; =20 - dev_arg =3D g_strdup_printf("-device %s,netdev=3D" NETNAME, model); - test_pxe_one(dev_arg, false); - g_free(dev_arg); + test_pxe_one(test, false); +} + +static void test_batch(const testdef_t *tests) +{ + int i; + + for (i =3D 0; tests[i].machine; i++) { + const testdef_t *test =3D &tests[i]; + char *testname; + + testname =3D g_strdup_printf("pxe/ipv4/%s/%s", + test->machine, test->model); + qtest_add_data_func(testname, test, test_pxe_ipv4); + g_free(testname); + } } =20 int main(int argc, char *argv[]) @@ -59,24 +108,17 @@ int main(int argc, char *argv[]) g_test_init(&argc, &argv, NULL); =20 if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { - qtest_add_data_func("pxe/e1000", "e1000", test_pxe_ipv4); - qtest_add_data_func("pxe/virtio", "virtio-net-pci", test_pxe_ipv4); + test_batch(x86_tests); if (g_test_slow()) { - qtest_add_data_func("pxe/ne2000", "ne2k_pci", test_pxe_ipv4); - qtest_add_data_func("pxe/eepro100", "i82550", test_pxe_ipv4); - qtest_add_data_func("pxe/pcnet", "pcnet", test_pxe_ipv4); - qtest_add_data_func("pxe/rtl8139", "rtl8139", test_pxe_ipv4); - qtest_add_data_func("pxe/vmxnet3", "vmxnet3", test_pxe_ipv4); + test_batch(x86_tests_slow); } } else if (strcmp(arch, "ppc64") =3D=3D 0) { - qtest_add_data_func("pxe/spapr-vlan", "spapr-vlan", test_pxe_ipv4); + test_batch(ppc64_tests); if (g_test_slow()) { - qtest_add_data_func("pxe/virtio", "virtio-net-pci", test_pxe_i= pv4); - qtest_add_data_func("pxe/e1000", "e1000", test_pxe_ipv4); + test_batch(ppc64_tests_slow); } } else if (g_str_equal(arch, "s390x")) { - qtest_add_data_func("pxe/virtio-ccw", - "virtio-net-ccw,bootindex=3D1", test_pxe_ipv4); + test_batch(s390x_tests); } ret =3D g_test_run(); boot_sector_cleanup(disk); --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513867760408923.9451958017906; Thu, 21 Dec 2017 06:49:20 -0800 (PST) Received: from localhost ([::1]:53251 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS29g-0007B2-GC for importer@patchew.org; Thu, 21 Dec 2017 09:49:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1qb-0007t6-Al for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1qa-0005hY-Dq for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55152) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1qa-0005h2-6W for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:20 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 66E624E334; Thu, 21 Dec 2017 14:29:19 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with SMTP id B55FA3819B; Thu, 21 Dec 2017 14:29:18 +0000 (UTC) Date: Thu, 21 Dec 2017 16:29:18 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-14-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 21 Dec 2017 14:29:19 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 13/25] tests/pxe-test: Test net booting over IPv6 in some cases X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Cornelia Huck , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Gibson This adds IPv6 net boot testing (in addition to IPv4) when in slow test mode on ppc64 or s390. IPv6 PXE doesn't seem to work on x86, I'm guessing our BIOS image doesn't support it. Signed-off-by: David Gibson Reviewed-by: Thomas Huth Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/pxe-test.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/tests/pxe-test.c b/tests/pxe-test.c index 4758ce7..5689c7d 100644 --- a/tests/pxe-test.c +++ b/tests/pxe-test.c @@ -81,7 +81,14 @@ static void test_pxe_ipv4(gconstpointer data) test_pxe_one(test, false); } =20 -static void test_batch(const testdef_t *tests) +static void test_pxe_ipv6(gconstpointer data) +{ + const testdef_t *test =3D data; + + test_pxe_one(test, true); +} + +static void test_batch(const testdef_t *tests, bool ipv6) { int i; =20 @@ -93,6 +100,13 @@ static void test_batch(const testdef_t *tests) test->machine, test->model); qtest_add_data_func(testname, test, test_pxe_ipv4); g_free(testname); + + if (ipv6) { + testname =3D g_strdup_printf("pxe/ipv6/%s/%s", + test->machine, test->model); + qtest_add_data_func(testname, test, test_pxe_ipv6); + g_free(testname); + } } } =20 @@ -108,17 +122,17 @@ int main(int argc, char *argv[]) g_test_init(&argc, &argv, NULL); =20 if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { - test_batch(x86_tests); + test_batch(x86_tests, false); if (g_test_slow()) { - test_batch(x86_tests_slow); + test_batch(x86_tests_slow, false); } } else if (strcmp(arch, "ppc64") =3D=3D 0) { - test_batch(ppc64_tests); + test_batch(ppc64_tests, g_test_slow()); if (g_test_slow()) { - test_batch(ppc64_tests_slow); + test_batch(ppc64_tests_slow, true); } } else if (g_str_equal(arch, "s390x")) { - test_batch(s390x_tests); + test_batch(s390x_tests, g_test_slow()); } ret =3D g_test_run(); boot_sector_cleanup(disk); --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513868303685322.97052318158126; Thu, 21 Dec 2017 06:58:23 -0800 (PST) Received: from localhost ([::1]:53427 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS2Ib-0006Y7-Go for importer@patchew.org; Thu, 21 Dec 2017 09:58:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45873) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1qd-0007vC-8M for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1qc-0005j2-Fd for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52324) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1qc-0005iZ-8H for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:22 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 636E1C00DBB1; Thu, 21 Dec 2017 14:29:21 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with SMTP id 035BA3819B; Thu, 21 Dec 2017 14:29:19 +0000 (UTC) Date: Thu, 21 Dec 2017 16:29:19 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-15-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 21 Dec 2017 14:29:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 14/25] tests/pxe-test: Add some extra tests X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Cornelia Huck , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Gibson Previously virtio-net was only tested for ppc64 in "slow" mode. That doesn't make much sense since virtio-net is used much more often in practice than the spapr-vlan device which was tested always. So, move virtio-net to always be tested on ppc64. We had no tests at all for the q35 machine, which doesn't seem wise given its increasing prominence. Add a couple of tests for it, including testing the newer e1000e adapter. Signed-off-by: David Gibson Reviewed-by: Thomas Huth Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/pxe-test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/pxe-test.c b/tests/pxe-test.c index 5689c7d..5ca8480 100644 --- a/tests/pxe-test.c +++ b/tests/pxe-test.c @@ -30,6 +30,8 @@ typedef struct testdef { static testdef_t x86_tests[] =3D { { "pc", "e1000" }, { "pc", "virtio-net-pci" }, + { "q35", "e1000e" }, + { "q35", "virtio-net-pci", }, { NULL }, }; =20 @@ -43,11 +45,11 @@ static testdef_t x86_tests_slow[] =3D { =20 static testdef_t ppc64_tests[] =3D { { "pseries", "spapr-vlan" }, + { "pseries", "virtio-net-pci", }, { NULL }, }; =20 static testdef_t ppc64_tests_slow[] =3D { - { "pseries", "virtio-net-pci", }, { "pseries", "e1000" }, { NULL }, }; --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513867940389439.71923082518174; Thu, 21 Dec 2017 06:52:20 -0800 (PST) Received: from localhost ([::1]:53295 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS2Ck-0001Ew-89 for importer@patchew.org; Thu, 21 Dec 2017 09:52:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1qm-00083o-MM for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1ql-0005q4-LW for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52394) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1qg-0005lS-K0; Thu, 21 Dec 2017 09:29:26 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B86D2C00DBB1; Thu, 21 Dec 2017 14:29:25 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id AEBE317DC6; Thu, 21 Dec 2017 14:29:22 +0000 (UTC) Date: Thu, 21 Dec 2017 16:29:21 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-16-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 21 Dec 2017 14:29:25 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 15/25] hw/block/nvme: QOM'ify PCI NVME X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Max Reitz , Keith Busch Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/block/nvme.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 441e21e..9c5f898 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -920,9 +920,9 @@ static const MemoryRegionOps nvme_cmb_ops =3D { }, }; =20 -static int nvme_init(PCIDevice *pci_dev) +static void nvme_realize(PCIDevice *pci, Error **errp) { - NvmeCtrl *n =3D NVME(pci_dev); + NvmeCtrl *n =3D NVME(pci); NvmeIdCtrl *id =3D &n->id_ctrl; =20 int i; @@ -931,30 +931,33 @@ static int nvme_init(PCIDevice *pci_dev) Error *local_err =3D NULL; =20 if (!n->conf.blk) { - return -1; + error_setg(errp, "Block device missing"); + return; } =20 bs_size =3D blk_getlength(n->conf.blk); if (bs_size < 0) { - return -1; + error_setg_errno(errp, -bs_size, "Could not get length of device"); + return; } =20 blkconf_serial(&n->conf, &n->serial); if (!n->serial) { - return -1; + error_setg(errp, "Could not get device serial number"); + return; } blkconf_blocksizes(&n->conf); blkconf_apply_backend_options(&n->conf, blk_is_read_only(n->conf.blk), false, &local_err); if (local_err) { - error_report_err(local_err); - return -1; + error_propagate(errp, local_err); + return; } =20 - pci_conf =3D pci_dev->config; + pci_conf =3D pci->config; pci_conf[PCI_INTERRUPT_PIN] =3D 1; - pci_config_set_prog_interface(pci_dev->config, 0x2); - pci_config_set_class(pci_dev->config, PCI_CLASS_STORAGE_EXPRESS); + pci_config_set_prog_interface(pci->config, 0x2); + pci_config_set_class(pci->config, PCI_CLASS_STORAGE_EXPRESS); pcie_endpoint_cap_init(&n->parent_obj, 0x80); =20 n->num_namespaces =3D 1; @@ -1046,12 +1049,11 @@ static int nvme_init(PCIDevice *pci_dev) cpu_to_le64(n->ns_size >> id_ns->lbaf[NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas)].ds); } - return 0; } =20 -static void nvme_exit(PCIDevice *pci_dev) +static void nvme_exit(PCIDevice *pci) { - NvmeCtrl *n =3D NVME(pci_dev); + NvmeCtrl *n =3D NVME(pci); =20 nvme_clear_ctrl(n); g_free(n->namespaces); @@ -1061,7 +1063,7 @@ static void nvme_exit(PCIDevice *pci_dev) memory_region_unref(&n->ctrl_mem); } =20 - msix_uninit_exclusive_bar(pci_dev); + msix_uninit_exclusive_bar(pci); } =20 static Property nvme_props[] =3D { @@ -1081,7 +1083,7 @@ static void nvme_class_init(ObjectClass *oc, void *da= ta) DeviceClass *dc =3D DEVICE_CLASS(oc); PCIDeviceClass *pc =3D PCI_DEVICE_CLASS(oc); =20 - pc->init =3D nvme_init; + pc->realize =3D nvme_realize; pc->exit =3D nvme_exit; pc->class_id =3D PCI_CLASS_STORAGE_EXPRESS; pc->vendor_id =3D PCI_VENDOR_ID_INTEL; --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513868123115754.5202077278948; Thu, 21 Dec 2017 06:55:23 -0800 (PST) Received: from localhost ([::1]:53364 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS2Fi-0003mT-1V for importer@patchew.org; Thu, 21 Dec 2017 09:55:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1qp-00086T-D4 for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1qo-0005sa-Em for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39314) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1qo-0005rb-4P for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:34 -0500 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 40626820F3; Thu, 21 Dec 2017 14:29:33 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E4A6503B3; Thu, 21 Dec 2017 14:29:26 +0000 (UTC) Date: Thu, 21 Dec 2017 16:29:25 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-17-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent 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.26]); Thu, 21 Dec 2017 14:29:33 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 16/25] hw/pci-host/piix: QOM'ify the IGD Passthrough host bridge X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcel Apfelbaum , Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Marcel Apfelbaum --- hw/pci-host/piix.c | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c index effe3db..0e60834 100644 --- a/hw/pci-host/piix.c +++ b/hw/pci-host/piix.c @@ -804,60 +804,55 @@ static const IGDHostInfo igd_host_bridge_infos[] =3D { {0xa8, 4}, /* SNB: base of GTT stolen memory */ }; =20 -static int host_pci_config_read(int pos, int len, uint32_t *val) +static void host_pci_config_read(int pos, int len, uint32_t *val, Error **= errp) { - char path[PATH_MAX]; - int config_fd; - ssize_t size =3D sizeof(path); + int rc, config_fd; /* Access real host bridge. */ - int rc =3D snprintf(path, size, "/sys/bus/pci/devices/%04x:%02x:%02x.%= d/%s", - 0, 0, 0, 0, "config"); - int ret =3D 0; - - if (rc >=3D size || rc < 0) { - return -ENODEV; - } + char *path =3D g_strdup_printf("/sys/bus/pci/devices/%04x:%02x:%02x.%d= /%s", + 0, 0, 0, 0, "config"); =20 config_fd =3D open(path, O_RDWR); if (config_fd < 0) { - return -ENODEV; + error_setg_errno(errp, errno, "Failed to open: %s", path); + goto out; } =20 if (lseek(config_fd, pos, SEEK_SET) !=3D pos) { - ret =3D -errno; - goto out; + error_setg_errno(errp, errno, "Failed to seek: %s", path); + goto out_close_fd; } =20 do { rc =3D read(config_fd, (uint8_t *)val, len); } while (rc < 0 && (errno =3D=3D EINTR || errno =3D=3D EAGAIN)); if (rc !=3D len) { - ret =3D -errno; + error_setg_errno(errp, errno, "Failed to read: %s", path); } =20 -out: +out_close_fd: close(config_fd); - return ret; +out: + g_free(path); } =20 -static int igd_pt_i440fx_initfn(struct PCIDevice *pci_dev) +static void igd_pt_i440fx_realize(PCIDevice *pci_dev, Error **errp) { uint32_t val =3D 0; - int rc, i, num; + int i, num; int pos, len; + Error *local_err =3D NULL; =20 num =3D ARRAY_SIZE(igd_host_bridge_infos); for (i =3D 0; i < num; i++) { pos =3D igd_host_bridge_infos[i].offset; len =3D igd_host_bridge_infos[i].len; - rc =3D host_pci_config_read(pos, len, &val); - if (rc) { - return -ENODEV; + host_pci_config_read(pos, len, &val, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; } pci_default_write_config(pci_dev, pos, val, len); } - - return 0; } =20 static void igd_passthrough_i440fx_class_init(ObjectClass *klass, void *da= ta) @@ -865,7 +860,7 @@ static void igd_passthrough_i440fx_class_init(ObjectCla= ss *klass, void *data) DeviceClass *dc =3D DEVICE_CLASS(klass); PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); =20 - k->init =3D igd_pt_i440fx_initfn; + k->realize =3D igd_pt_i440fx_realize; dc->desc =3D "IGD Passthrough Host bridge"; } =20 --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513868652402878.744468430287; Thu, 21 Dec 2017 07:04:12 -0800 (PST) Received: from localhost ([::1]:53752 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS2OC-0003W4-26 for importer@patchew.org; Thu, 21 Dec 2017 10:04:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46061) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1qv-0008Bs-0s for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1qu-0005wA-3X for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39408) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1qt-0005vQ-TI for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:40 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1B611820E7; Thu, 21 Dec 2017 14:29:39 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id C52025278A; Thu, 21 Dec 2017 14:29:33 +0000 (UTC) Date: Thu, 21 Dec 2017 16:29:33 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-18-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 21 Dec 2017 14:29:39 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 17/25] hw/pci-host/xilinx: QOM'ify the AXI-PCIe host bridge X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcel Apfelbaum , Peter Maydell , Paul Burton , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Marcel Apfelbaum --- hw/pci-host/xilinx-pcie.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/hw/pci-host/xilinx-pcie.c b/hw/pci-host/xilinx-pcie.c index d2f88d1..53b561f 100644 --- a/hw/pci-host/xilinx-pcie.c +++ b/hw/pci-host/xilinx-pcie.c @@ -18,6 +18,7 @@ */ =20 #include "qemu/osdep.h" +#include "qapi/error.h" #include "hw/pci/pci_bridge.h" #include "hw/pci-host/xilinx-pcie.h" =20 @@ -267,24 +268,22 @@ static void xilinx_pcie_root_config_write(PCIDevice *= d, uint32_t address, } } =20 -static int xilinx_pcie_root_init(PCIDevice *dev) +static void xilinx_pcie_root_realize(PCIDevice *pci_dev, Error **errp) { - BusState *bus =3D qdev_get_parent_bus(DEVICE(dev)); + BusState *bus =3D qdev_get_parent_bus(DEVICE(pci_dev)); XilinxPCIEHost *s =3D XILINX_PCIE_HOST(bus->parent); =20 - pci_set_word(dev->config + PCI_COMMAND, + pci_set_word(pci_dev->config + PCI_COMMAND, PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); - pci_set_word(dev->config + PCI_MEMORY_BASE, s->mmio_base >> 16); - pci_set_word(dev->config + PCI_MEMORY_LIMIT, + pci_set_word(pci_dev->config + PCI_MEMORY_BASE, s->mmio_base >> 16); + pci_set_word(pci_dev->config + PCI_MEMORY_LIMIT, ((s->mmio_base + s->mmio_size - 1) >> 16) & 0xfff0); =20 - pci_bridge_initfn(dev, TYPE_PCI_BUS); + pci_bridge_initfn(pci_dev, TYPE_PCI_BUS); =20 - if (pcie_endpoint_cap_v1_init(dev, 0x80) < 0) { - hw_error("Failed to initialize PCIe capability"); + if (pcie_endpoint_cap_v1_init(pci_dev, 0x80) < 0) { + error_setg(errp, "Failed to initialize PCIe capability"); } - - return 0; } =20 static void xilinx_pcie_root_class_init(ObjectClass *klass, void *data) @@ -300,7 +299,7 @@ static void xilinx_pcie_root_class_init(ObjectClass *kl= ass, void *data) k->class_id =3D PCI_CLASS_BRIDGE_HOST; k->is_express =3D true; k->is_bridge =3D true; - k->init =3D xilinx_pcie_root_init; + k->realize =3D xilinx_pcie_root_realize; k->exit =3D pci_bridge_exitfn; dc->reset =3D pci_bridge_reset; k->config_read =3D xilinx_pcie_root_config_read; --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513868305467385.2703242285959; Thu, 21 Dec 2017 06:58:25 -0800 (PST) Received: from localhost ([::1]:53428 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS2Id-0006ZS-9X for importer@patchew.org; Thu, 21 Dec 2017 09:58:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46107) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1qw-0008Cs-PI for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1qv-0005xn-UB for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56562) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1qv-0005xB-Nt for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:41 -0500 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 DC15913AA3; Thu, 21 Dec 2017 14:29:40 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id D164160C80; Thu, 21 Dec 2017 14:29:39 +0000 (UTC) Date: Thu, 21 Dec 2017 16:29:39 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-19-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent 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.29]); Thu, 21 Dec 2017 14:29:40 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 18/25] hw/pci: remove obsolete PCIDevice->init() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcel Apfelbaum , Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Philippe Mathieu-Daud=C3=A9 All PCI devices are now QOM'ified. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Marcel Apfelbaum Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci.h | 1 - hw/pci/pci.c | 14 -------------- 2 files changed, 15 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 15ced96..497d75f 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -217,7 +217,6 @@ typedef struct PCIDeviceClass { DeviceClass parent_class; =20 void (*realize)(PCIDevice *dev, Error **errp); - int (*init)(PCIDevice *dev);/* TODO convert to realize() and remove */ PCIUnregisterFunc *exit; PCIConfigReadFunc *config_read; PCIConfigWriteFunc *config_write; diff --git a/hw/pci/pci.c b/hw/pci/pci.c index e8f9fc1..764081f 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2043,18 +2043,6 @@ static void pci_qdev_realize(DeviceState *qdev, Erro= r **errp) } } =20 -static void pci_default_realize(PCIDevice *dev, Error **errp) -{ - PCIDeviceClass *pc =3D PCI_DEVICE_GET_CLASS(dev); - - if (pc->init) { - if (pc->init(dev) < 0) { - error_setg(errp, "Device initialization failed"); - return; - } - } -} - PCIDevice *pci_create_multifunction(PCIBus *bus, int devfn, bool multifunc= tion, const char *name) { @@ -2527,13 +2515,11 @@ MemoryRegion *pci_address_space_io(PCIDevice *dev) static void pci_device_class_init(ObjectClass *klass, void *data) { DeviceClass *k =3D DEVICE_CLASS(klass); - PCIDeviceClass *pc =3D PCI_DEVICE_CLASS(klass); =20 k->realize =3D pci_qdev_realize; k->unrealize =3D pci_qdev_unrealize; k->bus_type =3D TYPE_PCI_BUS; k->props =3D pci_props; - pc->realize =3D pci_default_realize; } =20 static void pci_device_class_base_init(ObjectClass *klass, void *data) --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513867768971795.2825109295921; Thu, 21 Dec 2017 06:49:28 -0800 (PST) Received: from localhost ([::1]:53252 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS29s-0007GE-Sp for importer@patchew.org; Thu, 21 Dec 2017 09:49:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46138) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1r4-0008L3-8o for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1r0-00061H-Fu for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:20368) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1r0-00060R-9O for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:46 -0500 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 6894B6A7D2; Thu, 21 Dec 2017 14:29:45 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with SMTP id 5644A60C80; Thu, 21 Dec 2017 14:29:42 +0000 (UTC) Date: Thu, 21 Dec 2017 16:29:40 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-20-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent 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.27]); Thu, 21 Dec 2017 14:29:45 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 19/25] vhost-user: fix indentation in protocol specification X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Signed-off-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/interop/vhost-user.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/interop/vhost-user.txt b/docs/interop/vhost-user.txt index 954771d..fd8ac56 100644 --- a/docs/interop/vhost-user.txt +++ b/docs/interop/vhost-user.txt @@ -53,8 +53,8 @@ Depending on the request type, payload can be: =20 * A vring state description --------------- - | index | num | - --------------- + | index | num | + --------------- =20 Index: a 32-bit index Num: a 32-bit number --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513868827528903.1331630716508; Thu, 21 Dec 2017 07:07:07 -0800 (PST) Received: from localhost ([::1]:53820 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS2Qz-0006Gu-9U for importer@patchew.org; Thu, 21 Dec 2017 10:06:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46166) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1rD-0008Tx-PF for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:30:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1rA-000678-AD for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53096) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1rA-00066i-1X for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:29:56 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3C14FC074F1B; Thu, 21 Dec 2017 14:29:55 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with SMTP id 09237189A7; Thu, 21 Dec 2017 14:29:45 +0000 (UTC) Date: Thu, 21 Dec 2017 16:29:45 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-21-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 21 Dec 2017 14:29:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 20/25] vhost-user: document memory accesses X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Maxime Coquelin , Wei Wang , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi The vhost-user protocol specification does not define "guest address" and "user address". It does not explain how to access memory given such addresses. This patch explains how memory access works, including the IOTLB. Cc: Michael S. Tsirkin Cc: Maxime Coquelin Cc: Wei Wang Signed-off-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Maxime Coquelin --- docs/interop/vhost-user.txt | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/docs/interop/vhost-user.txt b/docs/interop/vhost-user.txt index fd8ac56..d49444e 100644 --- a/docs/interop/vhost-user.txt +++ b/docs/interop/vhost-user.txt @@ -66,11 +66,14 @@ Depending on the request type, payload can be: =20 Index: a 32-bit vring index Flags: a 32-bit vring flags - Descriptor: a 64-bit user address of the vring descriptor table - Used: a 64-bit user address of the vring used ring - Available: a 64-bit user address of the vring available ring + Descriptor: a 64-bit ring address of the vring descriptor table + Used: a 64-bit ring address of the vring used ring + Available: a 64-bit ring address of the vring available ring Log: a 64-bit guest address for logging =20 + Note that a ring address is an IOVA if VIRTIO_F_IOMMU_PLATFORM has been + negotiated. Otherwise it is a user address. + * Memory regions description --------------------------------------------------- | num regions | padding | region0 | ... | region7 | @@ -273,6 +276,30 @@ Once the source has finished migration, rings will be = stopped by the source. No further update must be done before rings are restarted. =20 +Memory access +------------- + +The master sends a list of vhost memory regions to the slave using the +VHOST_USER_SET_MEM_TABLE message. Each region has two base addresses: a g= uest +address and a user address. + +Messages contain guest addresses and/or user addresses to reference locati= ons +within the shared memory. The mapping of these addresses works as follows. + +User addresses map to the vhost memory region containing that user address. + +When the VIRTIO_F_IOMMU_PLATFORM feature has not been negotiated: + + * Guest addresses map to the vhost memory region containing that guest + address. + +When the VIRTIO_F_IOMMU_PLATFORM feature has been negotiated: + + * Guest addresses are also called I/O virtual addresses (IOVAs). They are + translated to user addresses via the IOTLB. + + * The vhost memory region guest address is not used. + IOMMU support ------------- =20 --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 151386927584337.80456965668316; Thu, 21 Dec 2017 07:14:35 -0800 (PST) Received: from localhost ([::1]:54270 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS2YH-0005DV-Ro for importer@patchew.org; Thu, 21 Dec 2017 10:14:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48635) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1vD-0003QJ-J7 for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:34:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1vA-00011H-5R for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:34:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34316) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1v9-00010j-T1 for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:34:04 -0500 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 1399C2DACEF; Thu, 21 Dec 2017 14:34:03 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with SMTP id B3EAC5DA67; Thu, 21 Dec 2017 14:33:41 +0000 (UTC) Date: Thu, 21 Dec 2017 16:33:40 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-22-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent 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]); Thu, 21 Dec 2017 14:34:03 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 21/25] intel_iommu: remove X86_IOMMU_PCI_DEVFN_MAX X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Yi L , Eduardo Habkost , Peter Xu , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Peter Xu We have PCI_DEVFN_MAX now. Signed-off-by: Peter Xu Reviewed-by: Liu, Yi L Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/i386/x86-iommu.h | 1 - hw/i386/intel_iommu.c | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/include/hw/i386/x86-iommu.h b/include/hw/i386/x86-iommu.h index ef89c0c..7c71fc7 100644 --- a/include/hw/i386/x86-iommu.h +++ b/include/hw/i386/x86-iommu.h @@ -31,7 +31,6 @@ #define X86_IOMMU_GET_CLASS(obj) \ OBJECT_GET_CLASS(X86IOMMUClass, obj, TYPE_X86_IOMMU_DEVICE) =20 -#define X86_IOMMU_PCI_DEVFN_MAX 256 #define X86_IOMMU_SID_INVALID (0xffff) =20 typedef struct X86IOMMUState X86IOMMUState; diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 3a5bb0b..c1fa08d 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -186,7 +186,7 @@ static void vtd_reset_context_cache(IntelIOMMUState *s) g_hash_table_iter_init(&bus_it, s->vtd_as_by_busptr); =20 while (g_hash_table_iter_next (&bus_it, NULL, (void**)&vtd_bus)) { - for (devfn_it =3D 0; devfn_it < X86_IOMMU_PCI_DEVFN_MAX; ++devfn_i= t) { + for (devfn_it =3D 0; devfn_it < PCI_DEVFN_MAX; ++devfn_it) { vtd_as =3D vtd_bus->dev_as[devfn_it]; if (!vtd_as) { continue; @@ -1002,7 +1002,7 @@ static void vtd_switch_address_space_all(IntelIOMMUSt= ate *s) =20 g_hash_table_iter_init(&iter, s->vtd_as_by_busptr); while (g_hash_table_iter_next(&iter, NULL, (void **)&vtd_bus)) { - for (i =3D 0; i < X86_IOMMU_PCI_DEVFN_MAX; i++) { + for (i =3D 0; i < PCI_DEVFN_MAX; i++) { if (!vtd_bus->dev_as[i]) { continue; } @@ -1294,7 +1294,7 @@ static void vtd_context_device_invalidate(IntelIOMMUS= tate *s, vtd_bus =3D vtd_find_as_from_bus_num(s, bus_n); if (vtd_bus) { devfn =3D VTD_SID_TO_DEVFN(source_id); - for (devfn_it =3D 0; devfn_it < X86_IOMMU_PCI_DEVFN_MAX; ++devfn_i= t) { + for (devfn_it =3D 0; devfn_it < PCI_DEVFN_MAX; ++devfn_it) { vtd_as =3D vtd_bus->dev_as[devfn_it]; if (vtd_as && ((devfn_it & mask) =3D=3D (devfn & mask))) { trace_vtd_inv_desc_cc_device(bus_n, VTD_PCI_SLOT(devfn_it), @@ -2699,7 +2699,7 @@ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, = PCIBus *bus, int devfn) *new_key =3D (uintptr_t)bus; /* No corresponding free() */ vtd_bus =3D g_malloc0(sizeof(VTDBus) + sizeof(VTDAddressSpace *) *= \ - X86_IOMMU_PCI_DEVFN_MAX); + PCI_DEVFN_MAX); vtd_bus->bus =3D bus; g_hash_table_insert(s->vtd_as_by_busptr, new_key, vtd_bus); } @@ -2982,7 +2982,7 @@ static AddressSpace *vtd_host_dma_iommu(PCIBus *bus, = void *opaque, int devfn) IntelIOMMUState *s =3D opaque; VTDAddressSpace *vtd_as; =20 - assert(0 <=3D devfn && devfn < X86_IOMMU_PCI_DEVFN_MAX); + assert(0 <=3D devfn && devfn < PCI_DEVFN_MAX); =20 vtd_as =3D vtd_find_add_as(s, bus, devfn); return &vtd_as->as; --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513869260993346.8955680766311; Thu, 21 Dec 2017 07:14:20 -0800 (PST) Received: from localhost ([::1]:54266 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS2Xs-0004or-K5 for importer@patchew.org; Thu, 21 Dec 2017 10:14:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48715) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1vO-0003Zd-U8 for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:34:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1vO-00018j-4N for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:34:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:23597) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1vN-00018M-Tu for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:34:18 -0500 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 14951C0AD1F3; Thu, 21 Dec 2017 14:34:17 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with SMTP id 79FED5C2F0; Thu, 21 Dec 2017 14:34:10 +0000 (UTC) Date: Thu, 21 Dec 2017 16:34:09 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-23-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent 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.31]); Thu, 21 Dec 2017 14:34:17 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 22/25] intel_iommu: fix error param in string X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Yi L , Eduardo Habkost , Peter Xu , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Peter Xu It should be caching-mode. It may confuse people when it pops up. Signed-off-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Liu, Yi L Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index c1fa08d..fe15d3b 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2327,7 +2327,7 @@ static void vtd_iommu_notify_flag_changed(IOMMUMemory= Region *iommu, IntelIOMMUNotifierNode *next_node =3D NULL; =20 if (!s->caching_mode && new & IOMMU_NOTIFIER_MAP) { - error_report("We need to set cache_mode=3D1 for intel-iommu to ena= ble " + error_report("We need to set caching-mode=3D1 for intel-iommu to e= nable " "device assignment with IOMMU protection."); exit(1); } --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513868489218179.6501060605758; Thu, 21 Dec 2017 07:01:29 -0800 (PST) Received: from localhost ([::1]:53477 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS2LU-0000eR-1F for importer@patchew.org; Thu, 21 Dec 2017 10:01:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1sO-000172-J8 for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:31:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1sH-0007EH-4M for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:31:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59750) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1sG-0007DX-TT for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:31:05 -0500 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 09F778B13C; Thu, 21 Dec 2017 14:31:04 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with SMTP id 9CED660C20; Thu, 21 Dec 2017 14:30:53 +0000 (UTC) Date: Thu, 21 Dec 2017 16:30:53 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-24-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent 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.28]); Thu, 21 Dec 2017 14:31:04 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 23/25] virtio-pci: Don't force Subsystem Vendor ID = Vendor ID X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Ladi Prosek , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ladi Prosek The statement being removed doesn't change anything as virtio PCI devices a= lready have Subsystem Vendor ID set to pci_default_sub_vendor_id (0x1af4), same as= Vendor ID. And the Virtio spec does not require the two to be equal, either: "The PCI Subsystem Vendor ID and the PCI Subsystem Device ID MAY reflect = the PCI Vendor and Device ID of the environment (for informational purposes by th= e driver)." Background: Following the recent virtio-win licensing change, several vendors are plann= ing to ship their own certified version of Windows guest Virtio drivers, potential= ly taking advantage of Windows Update as a distribution channel. It is therefore crit= ical that each vendor uses their own PCI Subsystem Vendor ID for Virtio devices to pr= event drivers from other vendors binding to it. This would be trivially done by adding: k->subsystem_vendor_id =3D ... to virtio_pci_class_init(). Except for the problematic statement deleted by= this patch, which reverts the Subsystem Vendor ID back to 0x1af4 for legacy devi= ces for no good reason. Signed-off-by: Ladi Prosek Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Gerd Hoffmann --- hw/virtio/virtio-pci.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 42b31fb..6c75cca 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1588,9 +1588,11 @@ static void virtio_pci_device_plugged(DeviceState *d= , Error **errp) "neither legacy nor transitional device."); return ; } - /* legacy and transitional */ - pci_set_word(config + PCI_SUBSYSTEM_VENDOR_ID, - pci_get_word(config + PCI_VENDOR_ID)); + /* + * Legacy and transitional devices use specific subsystem IDs. + * Note that the subsystem vendor ID (config + PCI_SUBSYSTEM_VENDO= R_ID) + * is set to PCI_SUBVENDOR_ID_REDHAT_QUMRANET by default. + */ pci_set_word(config + PCI_SUBSYSTEM_ID, virtio_bus_get_vdev_id(bus= )); } else { /* pure virtio-1.0 */ --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513869111752844.4604356354852; Thu, 21 Dec 2017 07:11:51 -0800 (PST) Received: from localhost ([::1]:54069 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS2Vd-0002cC-JM for importer@patchew.org; Thu, 21 Dec 2017 10:11:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47661) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1sZ-0001GA-VB for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:31:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1sV-0007RH-Tw for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:31:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50202) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1sV-0007Pj-KK for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:31:19 -0500 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 C65D23B743; Thu, 21 Dec 2017 14:31:18 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id 96C9C191BE; Thu, 21 Dec 2017 14:31:04 +0000 (UTC) Date: Thu, 21 Dec 2017 16:31:04 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-25-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent 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.30]); Thu, 21 Dec 2017 14:31:18 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 24/25] dump-guest-memory.py: fix "You can't do that without a process to debug" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Cleber Rosa , Laszlo Ersek , Eduardo Habkost , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Marc-Andr=C3=A9 Lureau If the script is run with a core (no running process), it produces an error: (gdb) dump-guest-memory /tmp/vmcore X86_64 guest RAM blocks: target_start target_end host_addr message count Reviewed-by: Laszlo Ersek Reviewed-by: Michael S. Tsirkin ---------------- ---------------- ---------------- ------- ----- 0000000000000000 00000000000a0000 00007f7935800000 added 1 00000000000a0000 00000000000b0000 00007f7934200000 added 2 00000000000c0000 00000000000ca000 00007f79358c0000 added 3 00000000000ca000 00000000000cd000 00007f79358ca000 joined 3 00000000000cd000 00000000000e8000 00007f79358cd000 joined 3 00000000000e8000 00000000000f0000 00007f79358e8000 joined 3 00000000000f0000 0000000000100000 00007f79358f0000 joined 3 0000000000100000 0000000080000000 00007f7935900000 joined 3 00000000fd000000 00000000fe000000 00007f7934200000 added 4 00000000fffc0000 0000000100000000 00007f7935600000 added 5 Python Exception You can't do that without a process to= debug.: Error occurred in Python command: You can't do that without a process to debug. Replace the object_resolve_path_type() function call call with a local volatile variable. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Laszlo Ersek Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/misc/vmcoreinfo.c | 3 +++ scripts/dump-guest-memory.py | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/misc/vmcoreinfo.c b/hw/misc/vmcoreinfo.c index 31db57a..a280552 100644 --- a/hw/misc/vmcoreinfo.c +++ b/hw/misc/vmcoreinfo.c @@ -35,6 +35,8 @@ static void vmcoreinfo_realize(DeviceState *dev, Error **= errp) { VMCoreInfoState *s =3D VMCOREINFO(dev); FWCfgState *fw_cfg =3D fw_cfg_find(); + /* for gdb script dump-guest-memory.py */ + static VMCoreInfoState * volatile vmcoreinfo_state G_GNUC_UNUSED; =20 /* Given that this function is executing, there is at least one VMCORE= INFO * device. Check if there are several. @@ -56,6 +58,7 @@ static void vmcoreinfo_realize(DeviceState *dev, Error **= errp) &s->vmcoreinfo, sizeof(s->vmcoreinfo), false); =20 qemu_register_reset(vmcoreinfo_reset, dev); + vmcoreinfo_state =3D s; } =20 static const VMStateDescription vmstate_vmcoreinfo =3D { diff --git a/scripts/dump-guest-memory.py b/scripts/dump-guest-memory.py index 1af26c1..09bec92 100644 --- a/scripts/dump-guest-memory.py +++ b/scripts/dump-guest-memory.py @@ -546,8 +546,7 @@ shape and this command should mostly work.""" return None =20 def add_vmcoreinfo(self): - vmci =3D '(VMCoreInfoState *)' + \ - 'object_resolve_path_type("", "vmcoreinfo", 0)' + vmci =3D 'vmcoreinfo_realize::vmcoreinfo_state' if not gdb.parse_and_eval("%s" % vmci) \ or not gdb.parse_and_eval("(%s)->has_vmcoreinfo" % vmci): return --=20 MST From nobody Mon May 6 03:02:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513868949708602.296354040314; Thu, 21 Dec 2017 07:09:09 -0800 (PST) Received: from localhost ([::1]:53924 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS2Sw-0008Pj-Fj for importer@patchew.org; Thu, 21 Dec 2017 10:08:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1sZ-0001Fn-Jz for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:31:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1sY-0007Sq-Gn for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:31:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37448) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1sY-0007SR-9z for qemu-devel@nongnu.org; Thu, 21 Dec 2017 09:31:22 -0500 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 760273A273; Thu, 21 Dec 2017 14:31:21 +0000 (UTC) Received: from redhat.com (ovpn-124-215.rdu2.redhat.com [10.10.124.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5ADE7503B9; Thu, 21 Dec 2017 14:31:19 +0000 (UTC) Date: Thu, 21 Dec 2017 16:31:18 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1513866427-27125-26-git-send-email-mst@redhat.com> References: <1513866427-27125-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1513866427-27125-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent 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.38]); Thu, 21 Dec 2017 14:31:21 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 25/25] smbus: do not immediately complete commands X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?utf-8?B?SGVydsOp?= Poussineau , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Herv=C3=A9 Poussineau PIIX4 errata says that "immediate polling of the Host Status Register BUSY bit may indicate that the SMBus is NOT busy." Due to this, some code does the following steps: (a) set parameters (b) start command (c) check for smbus busy bit set (to know that command started) (d) check for smbus busy bit not set (to know that command finished) Let (c) happen, by immediately setting the busy bit, and really executing the command when status register has been read once. This fixes a problem with AMIBIOS, which can now properly initialize the PI= IX4. Signed-off-by: Herv=C3=A9 Poussineau Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/i2c/pm_smbus.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c index 6fc3923..ec060d5 100644 --- a/hw/i2c/pm_smbus.c +++ b/hw/i2c/pm_smbus.c @@ -63,6 +63,9 @@ static void smb_transaction(PMSMBus *s) I2CBus *bus =3D s->smbus; int ret; =20 + assert(s->smb_stat & STS_HOST_BUSY); + s->smb_stat &=3D ~STS_HOST_BUSY; + SMBUS_DPRINTF("SMBus trans addr=3D0x%02x prot=3D0x%02x\n", addr, prot); /* Transaction isn't exec if STS_DEV_ERR bit set */ if ((s->smb_stat & STS_DEV_ERR) !=3D 0) { @@ -135,6 +138,13 @@ error: =20 } =20 +static void smb_transaction_start(PMSMBus *s) +{ + /* Do not execute immediately the command ; it will be + * executed when guest will read SMB_STAT register */ + s->smb_stat |=3D STS_HOST_BUSY; +} + static void smb_ioport_writeb(void *opaque, hwaddr addr, uint64_t val, unsigned width) { @@ -150,7 +160,7 @@ static void smb_ioport_writeb(void *opaque, hwaddr addr= , uint64_t val, case SMBHSTCNT: s->smb_ctl =3D val; if (val & 0x40) - smb_transaction(s); + smb_transaction_start(s); break; case SMBHSTCMD: s->smb_cmd =3D val; @@ -182,6 +192,10 @@ static uint64_t smb_ioport_readb(void *opaque, hwaddr = addr, unsigned width) switch(addr) { case SMBHSTSTS: val =3D s->smb_stat; + if (s->smb_stat & STS_HOST_BUSY) { + /* execute command now */ + smb_transaction(s); + } break; case SMBHSTCNT: s->smb_index =3D 0; --=20 MST