From nobody Thu Jan 26 19:47:45 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P2rpT59L7z3bnTL; Thu, 26 Jan 2023 19:47:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P2rpT3t7sz3CWd; Thu, 26 Jan 2023 19:47:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674762465; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8EeOGlmD67oTLCBBjvjvlyZsdf4I+jJhC9tNSgI1KrI=; b=XXdC91wXlP7gRojT/PGZvFKAEKWB/zGRbvi/ENY81G+ITQUlaNXh20JfO5Y72YycbruWij xqkvR5F5OWJLUtkShU2vkB5U1WkbqtFIf9Lv09fqc4eHx7IAhDfkoLuiCQI6IRztl0tut1 OPBJ/Tgt/W0pZwUF7uRBSfO6HirJ3E4yM2Ace52pH0s7x5fLIEom5/YXViZ071CVUm3cv6 DpT+y46sfjYbyCaREi88k+d/gGDoqMUeEfdnNZ8rg/CUycZCUa92+F2GrxGTcjq0Z1syBc btU08KxuvEStRDPoF4SOO4QZqnLhRMltlRpZmrSHc/92PYO4vFxzK0ltlxVHvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674762465; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8EeOGlmD67oTLCBBjvjvlyZsdf4I+jJhC9tNSgI1KrI=; b=yxjgLm53hDFnK7pwixKdcpdEhx0w8srrDOFQBingYehOnpctY+DwjQYr1V5agTj9sUd2Y6 Dx8RZr705igYJxdA4YElgNj0XsS+YGWR7aRyQbMHAoe8AN9zWUdfhvXZEcI5XQ8eORarVK rhouIZWK3ZMe6yqGqFquI1DXxgLrG5fJAWnIS9AWrJZuaDggUfRUtgOQbe+WXdLJGRAMYA reMpRgGxXDvFFPdPKCFcMmUiIRfUeVzfCOQzw8retIEyO5HSkREbx4/G1wshVmpsU60Z+s VIgQCFKFaT1nsCSdG4Od2FDSkzPWI1F6whjeqY5Cvgk4yTHYtU9/boCAKSrO1Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674762465; a=rsa-sha256; cv=none; b=OybcZoi8p1FcZ/HLmGLbu7fe0ma9pGVgAp5rX73Ke/xpdynsu90X9eaDv/qoRf+eh3ofZB Gw3313S71kpFfcrKGyCcfbNt1U5GVuPe7rLVkGDAWDD3POb59VV2LUqFJqE/qk9jQ8Y1gt hD+RLhJBWom88GDlkrelGD36AxWuSvkHmQ18CZJZPe33stFRPX8vl3pDGllMQInsTyp7CW 0BCSkqEDUwsrrmy2pALxjrAnHdVdZBHpWJ4ngcZa5wNTxg1OCA9UGox1WwZCgnYGgcpIkB DoUbF/UOE1jUOI47PgpIPGG7UsbuNPjzDcXZhTP0UrxkUoVXYO53WJhgQk84ww== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P2rpT2zLnzhMg; Thu, 26 Jan 2023 19:47:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30QJljlo007040; Thu, 26 Jan 2023 19:47:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30QJljHH007039; Thu, 26 Jan 2023 19:47:45 GMT (envelope-from git) Date: Thu, 26 Jan 2023 19:47:45 GMT Message-Id: <202301261947.30QJljHH007039@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: a9cbcdd96f4b - stable/13 - bhyve: Use designated initializers for virtio_consts tables List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a9cbcdd96f4bcbd8dcb76c937e3918aa0c5daebb Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=a9cbcdd96f4bcbd8dcb76c937e3918aa0c5daebb commit a9cbcdd96f4bcbd8dcb76c937e3918aa0c5daebb Author: Mark Johnston AuthorDate: 2022-09-29 15:53:04 +0000 Commit: John Baldwin CommitDate: 2023-01-26 19:30:39 +0000 bhyve: Use designated initializers for virtio_consts tables This is easier to read and addresses some compiler warnings. One might expect these tables to be read-only but it seems that the snapshot/restore code may modify them. MFC after: 2 weeks (cherry picked from commit 6cb261620da3a9888f7a09244a8efe691c12ae47) --- usr.sbin/bhyve/pci_virtio_9p.c | 18 ++++++++---------- usr.sbin/bhyve/pci_virtio_block.c | 24 ++++++++++++------------ usr.sbin/bhyve/pci_virtio_console.c | 18 ++++++++---------- usr.sbin/bhyve/pci_virtio_input.c | 16 +++++++--------- usr.sbin/bhyve/pci_virtio_net.c | 23 +++++++++++------------ usr.sbin/bhyve/pci_virtio_rnd.c | 16 ++++++---------- usr.sbin/bhyve/pci_virtio_scsi.c | 17 ++++++++--------- 7 files changed, 60 insertions(+), 72 deletions(-) diff --git a/usr.sbin/bhyve/pci_virtio_9p.c b/usr.sbin/bhyve/pci_virtio_9p.c index c741f0f94d9f..1ed0eba6a8ed 100644 --- a/usr.sbin/bhyve/pci_virtio_9p.c +++ b/usr.sbin/bhyve/pci_virtio_9p.c @@ -105,18 +105,16 @@ static int pci_vt9p_cfgread(void *, int, int, uint32_t *); static void pci_vt9p_neg_features(void *, uint64_t); static struct virtio_consts vt9p_vi_consts = { - "vt9p", /* our name */ - 1, /* we support 1 virtqueue */ - VT9P_CONFIGSPACESZ, /* config reg size */ - pci_vt9p_reset, /* reset */ - pci_vt9p_notify, /* device-wide qnotify */ - pci_vt9p_cfgread, /* read virtio config */ - NULL, /* write virtio config */ - pci_vt9p_neg_features, /* apply negotiated features */ - (1 << 0), /* our capabilities */ + .vc_name = "vt9p", + .vc_nvq = 1, + .vc_cfgsize = VT9P_CONFIGSPACESZ, + .vc_reset = pci_vt9p_reset, + .vc_qnotify = pci_vt9p_notify, + .vc_cfgread = pci_vt9p_cfgread, + .vc_apply_features = pci_vt9p_neg_features, + .vc_hv_caps = (1 << 0), }; - static void pci_vt9p_reset(void *vsc) { diff --git a/usr.sbin/bhyve/pci_virtio_block.c b/usr.sbin/bhyve/pci_virtio_block.c index 1459f0e6c02d..8cdcbb777691 100644 --- a/usr.sbin/bhyve/pci_virtio_block.c +++ b/usr.sbin/bhyve/pci_virtio_block.c @@ -208,19 +208,19 @@ static int pci_vtblk_snapshot(void *, struct vm_snapshot_meta *); #endif static struct virtio_consts vtblk_vi_consts = { - "vtblk", /* our name */ - 1, /* we support 1 virtqueue */ - sizeof(struct vtblk_config), /* config reg size */ - pci_vtblk_reset, /* reset */ - pci_vtblk_notify, /* device-wide qnotify */ - pci_vtblk_cfgread, /* read PCI config */ - pci_vtblk_cfgwrite, /* write PCI config */ - NULL, /* apply negotiated features */ - VTBLK_S_HOSTCAPS, /* our capabilities */ + .vc_name = "vtblk", + .vc_nvq = 1, + .vc_cfgsize = sizeof(struct vtblk_config), + .vc_reset = pci_vtblk_reset, + .vc_qnotify = pci_vtblk_notify, + .vc_cfgread = pci_vtblk_cfgread, + .vc_cfgwrite = pci_vtblk_cfgwrite, + .vc_apply_features = NULL, + .vc_hv_caps = VTBLK_S_HOSTCAPS, #ifdef BHYVE_SNAPSHOT - pci_vtblk_pause, /* pause blockif threads */ - pci_vtblk_resume, /* resume blockif threads */ - pci_vtblk_snapshot, /* save / restore device state */ + .vc_pause = pci_vtblk_pause, + .vc_resume = pci_vtblk_resume, + .vc_snapshot = pci_vtblk_snapshot, #endif }; diff --git a/usr.sbin/bhyve/pci_virtio_console.c b/usr.sbin/bhyve/pci_virtio_console.c index 341f0857bade..663ead8d165e 100644 --- a/usr.sbin/bhyve/pci_virtio_console.c +++ b/usr.sbin/bhyve/pci_virtio_console.c @@ -169,18 +169,16 @@ static void pci_vtcon_announce_port(struct pci_vtcon_port *); static void pci_vtcon_open_port(struct pci_vtcon_port *, bool); static struct virtio_consts vtcon_vi_consts = { - "vtcon", /* our name */ - VTCON_MAXQ, /* we support VTCON_MAXQ virtqueues */ - sizeof(struct pci_vtcon_config), /* config reg size */ - pci_vtcon_reset, /* reset */ - NULL, /* device-wide qnotify */ - pci_vtcon_cfgread, /* read virtio config */ - pci_vtcon_cfgwrite, /* write virtio config */ - pci_vtcon_neg_features, /* apply negotiated features */ - VTCON_S_HOSTCAPS, /* our capabilities */ + .vc_name = "vtcon", + .vc_nvq = VTCON_MAXQ, + .vc_cfgsize = sizeof(struct pci_vtcon_config), + .vc_reset = pci_vtcon_reset, + .vc_cfgread = pci_vtcon_cfgread, + .vc_cfgwrite = pci_vtcon_cfgwrite, + .vc_apply_features = pci_vtcon_neg_features, + .vc_hv_caps = VTCON_S_HOSTCAPS, }; - static void pci_vtcon_reset(void *vsc) { diff --git a/usr.sbin/bhyve/pci_virtio_input.c b/usr.sbin/bhyve/pci_virtio_input.c index 4517333b1603..f0fdd9fcb7b0 100644 --- a/usr.sbin/bhyve/pci_virtio_input.c +++ b/usr.sbin/bhyve/pci_virtio_input.c @@ -159,15 +159,13 @@ static int pci_vtinput_cfgread(void *, int, int, uint32_t *); static int pci_vtinput_cfgwrite(void *, int, int, uint32_t); static struct virtio_consts vtinput_vi_consts = { - "vtinput", /* our name */ - VTINPUT_MAXQ, /* we support 1 virtqueue */ - sizeof(struct vtinput_config), /* config reg size */ - pci_vtinput_reset, /* reset */ - NULL, /* device-wide qnotify -- not used */ - pci_vtinput_cfgread, /* read virtio config */ - pci_vtinput_cfgwrite, /* write virtio config */ - NULL, /* apply negotiated features */ - 0, /* our capabilities */ + .vc_name = "vtinput", + .vc_nvq = VTINPUT_MAXQ, + .vc_cfgsize = sizeof(struct vtinput_config), + .vc_reset = pci_vtinput_reset, + .vc_cfgread = pci_vtinput_cfgread, + .vc_cfgwrite = pci_vtinput_cfgwrite, + .vc_hv_caps = 0, }; static void diff --git a/usr.sbin/bhyve/pci_virtio_net.c b/usr.sbin/bhyve/pci_virtio_net.c index 4122356ce70b..035c4e808cfe 100644 --- a/usr.sbin/bhyve/pci_virtio_net.c +++ b/usr.sbin/bhyve/pci_virtio_net.c @@ -145,19 +145,18 @@ static int pci_vtnet_snapshot(void *, struct vm_snapshot_meta *); #endif static struct virtio_consts vtnet_vi_consts = { - "vtnet", /* our name */ - VTNET_MAXQ - 1, /* we currently support 2 virtqueues */ - sizeof(struct virtio_net_config), /* config reg size */ - pci_vtnet_reset, /* reset */ - NULL, /* device-wide qnotify -- not used */ - pci_vtnet_cfgread, /* read PCI config */ - pci_vtnet_cfgwrite, /* write PCI config */ - pci_vtnet_neg_features, /* apply negotiated features */ - VTNET_S_HOSTCAPS, /* our capabilities */ + .vc_name = "vtnet", + .vc_nvq = VTNET_MAXQ - 1, + .vc_cfgsize = sizeof(struct virtio_net_config), + .vc_reset = pci_vtnet_reset, + .vc_cfgread = pci_vtnet_cfgread, + .vc_cfgwrite = pci_vtnet_cfgwrite, + .vc_apply_features = pci_vtnet_neg_features, + .vc_hv_caps = VTNET_S_HOSTCAPS, #ifdef BHYVE_SNAPSHOT - pci_vtnet_pause, /* pause rx/tx threads */ - pci_vtnet_resume, /* resume rx/tx threads */ - pci_vtnet_snapshot, /* save / restore device state */ + .vc_pause = pci_vtnet_pause, + .vc_resume = pci_vtnet_resume, + .vc_snapshot = pci_vtnet_snapshot, #endif }; diff --git a/usr.sbin/bhyve/pci_virtio_rnd.c b/usr.sbin/bhyve/pci_virtio_rnd.c index db8dc143e0b2..4049494177f9 100644 --- a/usr.sbin/bhyve/pci_virtio_rnd.c +++ b/usr.sbin/bhyve/pci_virtio_rnd.c @@ -84,18 +84,14 @@ static void pci_vtrnd_reset(void *); static void pci_vtrnd_notify(void *, struct vqueue_info *); static struct virtio_consts vtrnd_vi_consts = { - "vtrnd", /* our name */ - 1, /* we support 1 virtqueue */ - 0, /* config reg size */ - pci_vtrnd_reset, /* reset */ - pci_vtrnd_notify, /* device-wide qnotify */ - NULL, /* read virtio config */ - NULL, /* write virtio config */ - NULL, /* apply negotiated features */ - 0, /* our capabilities */ + .vc_name = "vtrnd", + .vc_nvq = 1, + .vc_cfgsize = 0, + .vc_reset = pci_vtrnd_reset, + .vc_qnotify = pci_vtrnd_notify, + .vc_hv_caps = 0, }; - static void pci_vtrnd_reset(void *vsc) { diff --git a/usr.sbin/bhyve/pci_virtio_scsi.c b/usr.sbin/bhyve/pci_virtio_scsi.c index b33e6e432dea..236780e3b113 100644 --- a/usr.sbin/bhyve/pci_virtio_scsi.c +++ b/usr.sbin/bhyve/pci_virtio_scsi.c @@ -248,15 +248,14 @@ static int pci_vtscsi_init_queue(struct pci_vtscsi_softc *, static int pci_vtscsi_init(struct vmctx *, struct pci_devinst *, nvlist_t *); static struct virtio_consts vtscsi_vi_consts = { - "vtscsi", /* our name */ - VTSCSI_MAXQ, /* we support 2+n virtqueues */ - sizeof(struct pci_vtscsi_config), /* config reg size */ - pci_vtscsi_reset, /* reset */ - NULL, /* device-wide qnotify */ - pci_vtscsi_cfgread, /* read virtio config */ - pci_vtscsi_cfgwrite, /* write virtio config */ - pci_vtscsi_neg_features, /* apply negotiated features */ - 0, /* our capabilities */ + .vc_name = "vtscsi", + .vc_nvq = VTSCSI_MAXQ, + .vc_cfgsize = sizeof(struct pci_vtscsi_config), + .vc_reset = pci_vtscsi_reset, + .vc_cfgread = pci_vtscsi_cfgread, + .vc_cfgwrite = pci_vtscsi_cfgwrite, + .vc_apply_features = pci_vtscsi_neg_features, + .vc_hv_caps = 0, }; static void *