From nobody Thu Sep 29 16:37:44 2022 X-Original-To: dev-commits-src-main@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 4MdfD86wsKz4dgpB; Thu, 29 Sep 2022 16:37:44 +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 4MdfD866ycz43H1; Thu, 29 Sep 2022 16:37:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664469464; 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=OEljMQ1t2qaBwPeTZo6F5JZUKibJekD7zSPKYQNWkcA=; b=op89crYzlaXLBIvy9D3lbt3V8Oeu6JSuiuzkczVqgQ63zX34Z1JJ8ufglr+WzPim6UDqtg rDaRAf0/AEPu86HuA6xn18f2rq6QwMgnP9pa8k20rwaCe/MfnhbxOUG68ykn/EvxrDTz0D Cu/xgK3B2W85HXdxtKjIR24hYiOLopFkvIu0EdRMjphE4ik19U/cfXy8qZ/SmHEaItxJEy mjEPROJTGOVbc3FCLhHu7NF8ItcE8M1SKXxqLit4wwxhL4osz+bUVKaqRJ0+JfyQOs/jIR PFbZ2dWvohygLcnENpz0iLEfX0BxkEsQzI6S4UxS31px6zkUYvBi2NfPBcHmXQ== 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 4MdfD852PVzsXY; Thu, 29 Sep 2022 16:37:44 +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 28TGbiWH090468; Thu, 29 Sep 2022 16:37:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28TGbirs090467; Thu, 29 Sep 2022 16:37:44 GMT (envelope-from git) Date: Thu, 29 Sep 2022 16:37:44 GMT Message-Id: <202209291637.28TGbirs090467@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 6cb261620da3 - main - bhyve: Use designated initializers for virtio_consts tables List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6cb261620da3a9888f7a09244a8efe691c12ae47 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664469464; 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=OEljMQ1t2qaBwPeTZo6F5JZUKibJekD7zSPKYQNWkcA=; b=jjWzr92spjsaNkO3svrBhI0A0+CuN2siQWG37CwtYTQHZ+4OaCM1sQc16brnW6LD60dUYj Hb3i3XawR72sPpOCb1GVSpOo/ysOP+/Pk5XkH2bNEhlSpx+Pe2h76wZ2DSHrB5QilZk9lZ dZdhT9X5z+wkQ1yd8O4maGRWz8pp11xeH9FzPtUH2TUHNgAVQSDu7DVnBqi07eiBOlSHkE LLl6GZWuta2WUNgg9Gp0HO96v/76cwiBCGLUZOR698s8vc4u/zkypfMYi7X8bKC8MeK+AU B0PaB2P3dbm1mcL1ffSpm5MO66fG4yeroLQT8uS8m+XPkS/4fxR0TIhfiaJlKg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664469464; a=rsa-sha256; cv=none; b=ZORMebSXA3gue/nt2GPPE7PtbjvgL8LbtEmVU84FsclJ7B00Vjgh7POgTSD45+IITwAbTL jf33NnNkTNhShf7Ed6Mo/+lsoV1VuCJ4+uiQ2H46fcyQXrcU0YkomPRKLvtxf/8YX+fgQc XwD2HdtCRKqICdRocqshh4BtgnZgFG7jgIyKIz6Nqr0p+7kp97qPMDSDk0TIT9SUmiOrec IrzH9fz0utAsaI64RiFShSXABeI6na8NnJH/XlPUHZyWLtRAl85IK3HCnwVMpQzK1xXmuZ Jmuw5ISXaoXZ0LdiMbjDl9aFnVm09napvZEyYABbjEY39fSs4dzUr/utG3KDPA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=6cb261620da3a9888f7a09244a8efe691c12ae47 commit 6cb261620da3a9888f7a09244a8efe691c12ae47 Author: Mark Johnston AuthorDate: 2022-09-29 15:53:04 +0000 Commit: Mark Johnston CommitDate: 2022-09-29 16:36:44 +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 --- 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 404213d907e7..e3d5264b8b22 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 a0c7e2c585b4..068a3f267b09 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 b50b6e9fd047..235f96eca233 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 *