From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43375) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTUko-0006YL-VO for qemu-devel@nongnu.org; Wed, 10 Feb 2016 08:24:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aTUkn-0005lg-Uf for qemu-devel@nongnu.org; Wed, 10 Feb 2016 08:24:22 -0500 References: <1455106941-2934-1-git-send-email-marcel@redhat.com> <1455106941-2934-3-git-send-email-marcel@redhat.com> <56BB361B.6030705@redhat.com> From: Marcel Apfelbaum Message-ID: <56BB39FD.5000000@gmail.com> Date: Wed, 10 Feb 2016 15:24:13 +0200 MIME-Version: 1.0 In-Reply-To: <56BB361B.6030705@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/2] hw/virtio: group virtio flags into an enum Reply-To: marcel@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laurent Vivier , Marcel Apfelbaum , qemu-devel@nongnu.org Cc: jasowang@redhat.com, qemu-stable@nongnu.org, mst@redhat.com On 02/10/2016 03:07 PM, Laurent Vivier wrote: > > > On 10/02/2016 13:22, Marcel Apfelbaum wrote: >> Minimizes the possibility to assign >> the same bit to different features. >> >> Signed-off-by: Marcel Apfelbaum >> --- >> hw/virtio/virtio-pci.h | 16 ++++++++++------ >> 1 file changed, 10 insertions(+), 6 deletions(-) >> >> diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h >> index 6686b10..817bcde 100644 >> --- a/hw/virtio/virtio-pci.h >> +++ b/hw/virtio/virtio-pci.h >> @@ -58,6 +58,16 @@ typedef struct VirtioBusClass VirtioPCIBusClass; >> #define VIRTIO_PCI_BUS_CLASS(klass) \ >> OBJECT_CLASS_CHECK(VirtioPCIBusClass, klass, TYPE_VIRTIO_PCI_BUS) >> >> +enum { >> + VIRTIO_PCI_FLAG_BUS_MASTER_BUG_MIGRATION_BIT, >> + VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, >> + VIRTIO_PCI_FLAG_DISABLE_LEGACY_BIT, >> + VIRTIO_PCI_FLAG_DISABLE_MODERN_BIT, >> + VIRTIO_PCI_FLAG_MIGRATE_EXTRA_BIT, >> + VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY_BIT, >> + VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT, >> +}; > > You can keep the "#define", doing something like this after the enum: > > #define VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT > > So, if someone includes this ".h" out of qemu and wants to use some > "#ifdef" to see if the bit is defined, it always works. > (see for an example, /usr/include/linux/rtnetlink.h). Thanks for the idea, but I don't think anyone would want to use those out of qemu :) I am also afraid that developers will forget to add it to the enum and will still use the defines only. > >> + >> /* Need to activate work-arounds for buggy guests at vmstate load. */ >> #define VIRTIO_PCI_FLAG_BUS_MASTER_BUG_MIGRATION_BIT 0 > > You should remove this one too. How did I manage to miss it? Thanks! I'll send a v2 Marcel > >> #define VIRTIO_PCI_FLAG_BUS_MASTER_BUG_MIGRATION \ >> @@ -65,23 +75,17 @@ typedef struct VirtioBusClass VirtioPCIBusClass; >> >> /* Performance improves when virtqueue kick processing is decoupled from the >> * vcpu thread using ioeventfd for some devices. */ >> -#define VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT 1 >> #define VIRTIO_PCI_FLAG_USE_IOEVENTFD (1 << VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT) >> >> /* virtio version flags */ >> -#define VIRTIO_PCI_FLAG_DISABLE_LEGACY_BIT 2 >> -#define VIRTIO_PCI_FLAG_DISABLE_MODERN_BIT 3 >> -#define VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT 6 >> #define VIRTIO_PCI_FLAG_DISABLE_LEGACY (1 << VIRTIO_PCI_FLAG_DISABLE_LEGACY_BIT) >> #define VIRTIO_PCI_FLAG_DISABLE_MODERN (1 << VIRTIO_PCI_FLAG_DISABLE_MODERN_BIT) >> #define VIRTIO_PCI_FLAG_DISABLE_PCIE (1 << VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT) >> >> /* migrate extra state */ >> -#define VIRTIO_PCI_FLAG_MIGRATE_EXTRA_BIT 4 >> #define VIRTIO_PCI_FLAG_MIGRATE_EXTRA (1 << VIRTIO_PCI_FLAG_MIGRATE_EXTRA_BIT) >> >> /* have pio notification for modern device ? */ >> -#define VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY_BIT 5 >> #define VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY \ >> (1 << VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY_BIT) >> >> > >