Re: [PATCH v5 11/21] virtio-pci: Proxy for virtio-mem

2020-07-06 Thread David Hildenbrand
On 06.07.20 17:28, Cornelia Huck wrote:
> On Fri, 26 Jun 2020 09:22:38 +0200
> David Hildenbrand  wrote:
> 
>> Let's add a proxy for virtio-mem, make it a memory device, and
>> pass-through the properties.
>>
>> Reviewed-by: Pankaj Gupta 
>> Cc: "Michael S. Tsirkin" 
>> Cc: Marcel Apfelbaum 
>> Cc: "Dr. David Alan Gilbert" 
>> Cc: Igor Mammedov 
>> Signed-off-by: David Hildenbrand 
>> ---
>>  hw/virtio/Makefile.objs|   1 +
>>  hw/virtio/virtio-mem-pci.c | 129 +
>>  hw/virtio/virtio-mem-pci.h |  33 ++
>>  include/hw/pci/pci.h   |   1 +
>>  4 files changed, 164 insertions(+)
>>  create mode 100644 hw/virtio/virtio-mem-pci.c
>>  create mode 100644 hw/virtio/virtio-mem-pci.h
> 
> (...)
> 
>> diff --git a/hw/virtio/virtio-mem-pci.c b/hw/virtio/virtio-mem-pci.c
>> new file mode 100644
>> index 00..b325303b32
>> --- /dev/null
>> +++ b/hw/virtio/virtio-mem-pci.c
>> @@ -0,0 +1,129 @@
>> +/*
>> + * Virtio MEM PCI device
>> + *
>> + * Copyright (C) 2020 Red Hat, Inc.
>> + *
>> + * Authors:
>> + *  David Hildenbrand 
>> + *
>> + * This work is licensed under the terms of the GNU GPL, version 2.
>> + * See the COPYING file in the top-level directory.
>> + */
>> +
>> +#include "qemu/osdep.h"
>> +#include "virtio-mem-pci.h"
>> +#include "hw/mem/memory-device.h"
>> +#include "qapi/error.h"
>> +
>> +static void virtio_mem_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
>> +{
>> +VirtIOMEMPCI *mem_pci = VIRTIO_MEM_PCI(vpci_dev);
>> +DeviceState *vdev = DEVICE(_pci->vdev);
>> +
> 
> As we were having that discussion for other devices recently: I think
> you want to use 
> 
> virtio_pci_force_virtio_1(vpci_dev);
> 
> here. (Or do it via the names in the type, as virtio-fs does, but I
> think I like forcing it better.)

Interesting. There is a PULL request pending which includes virtio-mem,
so I'll send that as an addon. Thanks!

-- 
Thanks,

David / dhildenb




Re: [PATCH v5 11/21] virtio-pci: Proxy for virtio-mem

2020-07-06 Thread Cornelia Huck
On Fri, 26 Jun 2020 09:22:38 +0200
David Hildenbrand  wrote:

> Let's add a proxy for virtio-mem, make it a memory device, and
> pass-through the properties.
> 
> Reviewed-by: Pankaj Gupta 
> Cc: "Michael S. Tsirkin" 
> Cc: Marcel Apfelbaum 
> Cc: "Dr. David Alan Gilbert" 
> Cc: Igor Mammedov 
> Signed-off-by: David Hildenbrand 
> ---
>  hw/virtio/Makefile.objs|   1 +
>  hw/virtio/virtio-mem-pci.c | 129 +
>  hw/virtio/virtio-mem-pci.h |  33 ++
>  include/hw/pci/pci.h   |   1 +
>  4 files changed, 164 insertions(+)
>  create mode 100644 hw/virtio/virtio-mem-pci.c
>  create mode 100644 hw/virtio/virtio-mem-pci.h

(...)

> diff --git a/hw/virtio/virtio-mem-pci.c b/hw/virtio/virtio-mem-pci.c
> new file mode 100644
> index 00..b325303b32
> --- /dev/null
> +++ b/hw/virtio/virtio-mem-pci.c
> @@ -0,0 +1,129 @@
> +/*
> + * Virtio MEM PCI device
> + *
> + * Copyright (C) 2020 Red Hat, Inc.
> + *
> + * Authors:
> + *  David Hildenbrand 
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2.
> + * See the COPYING file in the top-level directory.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "virtio-mem-pci.h"
> +#include "hw/mem/memory-device.h"
> +#include "qapi/error.h"
> +
> +static void virtio_mem_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
> +{
> +VirtIOMEMPCI *mem_pci = VIRTIO_MEM_PCI(vpci_dev);
> +DeviceState *vdev = DEVICE(_pci->vdev);
> +

As we were having that discussion for other devices recently: I think
you want to use 

virtio_pci_force_virtio_1(vpci_dev);

here. (Or do it via the names in the type, as virtio-fs does, but I
think I like forcing it better.)

> +qdev_set_parent_bus(vdev, BUS(_dev->bus));
> +object_property_set_bool(OBJECT(vdev), true, "realized", errp);
> +}