Re: [Qemu-devel] [RFC PATCH v0] numa: API to lookup NUMA node by address
On Thu, Jun 11, 2015 at 08:56:03AM +0200, Igor Mammedov wrote: > > > > And to make this work, it needs to be aware of NUMA information for > > > > hotplugged memory too. > > > I've checked spapr_populate_drconf_memory() from original series, > > > it needs to be aware at startup about address ranges -> node mapping > > > including mapping partitioning of whole hotplug memory range > > > (i.e. not actual hotplugged memory). > > > -numa node_mem & numa_set_mem_node_id() are sufficient for this purpose > > > > spapr_populate_drconf_memory() needs to know about node information for > > boot time memory as well as the hotplugged pc-dimm memory. Since chunks > > of hotplug memory range could be plugged into any node, we need to > > be able to locate the node id for such memory range. This is where > > numa_set_mem_node_id() call for each realized dimm will help. > So you are saying that spapr_populate_drconf_memory() doesn't need to know > in advance about unplugged memory ranges and could be updated at runtime. > (I've thought that device tree is build only at boot and guest can't > accept dynamic updates to it, therefore you'd need provide addr -> node_id > mapping at boot time including for not yet plugged memory). Here are we dynamically adding a device tree node at runtime when guest issues ibm,architecture-client-support call during early boot. Guest firmware (SLOF) has already been updated to support such dynamic update. During hotplug the node id information is also updated in ibm,dynamic-memory property that is present under this device tree node. Regards, Bharata.
Re: [Qemu-devel] [PATCH v3 1/2] ACPI: Add definitions for the SPCR table
On Wed, 10 Jun 2015 05:52:38 -0400 Andrew Jones wrote: > SPCR is the Serial Port Console Redirection Table. See the document > linked from http://uefi.org/acpi. For serial port types, "Interface > Type", see the documentation for the Debug Port Table 2 (DBG2). > > Signed-off-by: Andrew Jones > Tested-by: Shannon Zhao Reviewed-by: Igor Mammedov > --- > include/hw/acpi/acpi-defs.h | 32 > 1 file changed, 32 insertions(+) > > diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h > index 59cf277434b37..7b4bfb7494717 100644 > --- a/include/hw/acpi/acpi-defs.h > +++ b/include/hw/acpi/acpi-defs.h > @@ -197,6 +197,38 @@ enum { > }; > > /* > + * Serial Port Console Redirection Table (SPCR), Rev. 1.02 > + * > + * For .interface_type see Debug Port Table 2 (DBG2) serial port > + * subtypes in Table 3, Rev. May 22, 2012 > + */ > +struct AcpiSerialPortConsoleRedirection { > +ACPI_TABLE_HEADER_DEF > +uint8_t interface_type; > +uint8_t reserved1[3]; > +struct AcpiGenericAddress base_address; > +uint8_t interrupt_types; > +uint8_t irq; > +uint32_t gsi; > +uint8_t baud; > +uint8_t parity; > +uint8_t stopbits; > +uint8_t flowctrl; > +uint8_t term_type; > +uint8_t reserved2; > +uint16_t pci_device_id; > +uint16_t pci_vendor_id; > +uint8_t pci_bus; > +uint8_t pci_slot; > +uint8_t pci_func; > +uint32_t pci_flags; > +uint8_t pci_seg; > +uint32_t reserved3; > +} QEMU_PACKED; > +typedef struct AcpiSerialPortConsoleRedirection > + AcpiSerialPortConsoleRedirection; > + > +/* > * ACPI 1.0 Root System Description Table (RSDT) > */ > struct AcpiRsdtDescriptorRev1
Re: [Qemu-devel] [PATCH v3 2/2] hw/arm/virt-acpi-build: Add SPCR table
On Wed, 10 Jun 2015 05:52:39 -0400 Andrew Jones wrote: > Signed-off-by: Andrew Jones > Tested-by: Shannon Zhao Reviewed-by: Igor Mammedov > --- > hw/arm/virt-acpi-build.c | 43 ++- > 1 file changed, 42 insertions(+), 1 deletion(-) > > diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c > index a9373ccaca6cb..d5a8b9c0178ea 100644 > --- a/hw/arm/virt-acpi-build.c > +++ b/hw/arm/virt-acpi-build.c > @@ -84,6 +84,12 @@ static void acpi_dsdt_add_uart(Aml *scope, const > MemMapEntry *uart_memmap, > aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH, > AML_EXCLUSIVE, uart_irq)); > aml_append(dev, aml_name_decl("_CRS", crs)); > + > +/* The _ADR entry is used to link this device to the UART described > + * in the SPCR table, i.e. SPCR.base_address.address == _ADR. > + */ > +aml_append(dev, aml_name_decl("_ADR", aml_int(uart_memmap->base))); > + > aml_append(scope, dev); > } > > @@ -334,6 +340,38 @@ build_rsdp(GArray *rsdp_table, GArray *linker, unsigned > rsdt) > } > > static void > +build_spcr(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info) > +{ > +AcpiSerialPortConsoleRedirection *spcr; > +const MemMapEntry *uart_memmap = &guest_info->memmap[VIRT_UART]; > +int irq = guest_info->irqmap[VIRT_UART] + ARM_SPI_BASE; > + > +spcr = acpi_data_push(table_data, sizeof(*spcr)); > + > +spcr->interface_type = 0x3;/* ARM PL011 UART */ > + > +spcr->base_address.space_id = AML_SYSTEM_MEMORY; > +spcr->base_address.bit_width = 8; > +spcr->base_address.bit_offset = 0; > +spcr->base_address.access_width = 1; > +spcr->base_address.address = cpu_to_le64(uart_memmap->base); > + > +spcr->interrupt_types = (1 << 3); /* Bit[3] ARMH GIC interrupt */ > +spcr->gsi = cpu_to_le32(irq); /* Global System Interrupt */ > + > +spcr->baud = 3;/* Baud Rate: 3 = 9600 */ > +spcr->parity = 0; /* No Parity */ > +spcr->stopbits = 1;/* 1 Stop bit */ > +spcr->flowctrl = (1 << 1); /* Bit[1] = RTS/CTS hardware flow control > */ > +spcr->term_type = 0; /* Terminal Type: 0 = VT100 */ > + > +spcr->pci_device_id = 0x; /* PCI Device ID: not a PCI device */ > +spcr->pci_vendor_id = 0x; /* PCI Vendor ID: not a PCI device */ > + > +build_header(linker, table_data, (void *)spcr, "SPCR", sizeof(*spcr), 2); > +} > + > +static void > build_mcfg(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info) > { > AcpiTableMcfg *mcfg; > @@ -514,7 +552,7 @@ void virt_acpi_build(VirtGuestInfo *guest_info, > AcpiBuildTables *tables) > dsdt = tables_blob->len; > build_dsdt(tables_blob, tables->linker, guest_info); > > -/* FADT MADT GTDT pointed to by RSDT */ > +/* FADT MADT GTDT SPCR pointed to by RSDT */ > acpi_add_table(table_offsets, tables_blob); > build_fadt(tables_blob, tables->linker, dsdt); > > @@ -527,6 +565,9 @@ void virt_acpi_build(VirtGuestInfo *guest_info, > AcpiBuildTables *tables) > acpi_add_table(table_offsets, tables_blob); > build_mcfg(tables_blob, tables->linker, guest_info); > > +acpi_add_table(table_offsets, tables_blob); > +build_spcr(tables_blob, tables->linker, guest_info); > + > /* RSDT is pointed to by RSDP */ > rsdt = tables_blob->len; > build_rsdt(tables_blob, tables->linker, table_offsets);
[Qemu-devel] [PATCH] hw/vfio/platform: replace g_malloc0_n by g_malloc0
g_malloc0_n() is introduced since glib-2.24 while QEMU currently requires glib-2.22. This may cause a link error on some distributions. Signed-off-by: Eric Auger --- hw/vfio/platform.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index 35266a8..c0acc8b 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -346,8 +346,7 @@ static int vfio_populate_device(VFIODevice *vbasedev) return ret; } -vdev->regions = g_malloc0_n(vbasedev->num_regions, -sizeof(VFIORegion *)); +vdev->regions = g_malloc0(vbasedev->num_regions * sizeof(VFIORegion *)); for (i = 0; i < vbasedev->num_regions; i++) { struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) }; -- 1.8.3.2
[Qemu-devel] qemu freeze, seabios release
Hi, qemu soft freeze for 2.4 is just around the corner, time to think about the seabios release which should be included there. A new release from master isn't even planned yet[1], so I think we should go for a 1.8.2 stable release. So, if there are any fixes which should be cherry-picked into stable please speak up now. So far my list is pretty short: 87f848e vga: rework virtio-vga support cheers, Gerd [1] It probably makes sense to plan once the tpm support merge is complete.
[Qemu-devel] PING: RE: [PATCH RFC V3 1/4] Use Aff1 with mpidr This is an improved and KVM-aware alternative to
Hi Peter! > Hi. I think this patch largely makes sense, but I have some comments > below. If you want to fix these and resend as a standalone patch > I'm happy to apply that. How are things going? I have resent v4 of this on the very same day, and got no reaction from you since then. My vGICv3 implementation is waiting. It even has support for proposed in-kernel ITS emulation: http://www.mail-archive.com/kvm@vger.kernel.org/msg116057.html Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia
[Qemu-devel] [PULL 2/2] spice: ui_info tweaks
Use the new dpy_ui_info_supported function. Clarifies the control flow. Signed-off-by: Gerd Hoffmann --- ui/spice-display.c | 17 - 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/ui/spice-display.c b/ui/spice-display.c index 4e6356a..cc4a6ce 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -661,7 +661,10 @@ static int interface_client_monitors_config(QXLInstance *sin, { SimpleSpiceDisplay *ssd = container_of(sin, SimpleSpiceDisplay, qxl); QemuUIInfo info; -int rc; + +if (!dpy_ui_info_supported(ssd->dcl.con)) { +return 0; /* == not supported by guest */ +} if (!mc) { return 1; @@ -676,14 +679,10 @@ static int interface_client_monitors_config(QXLInstance *sin, info.width = mc->monitors[0].width; info.height = mc->monitors[0].height; } -rc = dpy_set_ui_info(ssd->dcl.con, &info); -dprint(1, "%s/%d: size %dx%d, rc %d <--- ==\n", - __func__, ssd->qxl.id, info.width, info.height, rc); -if (rc != 0) { -return 0; /* == not supported by guest */ -} else { -return 1; -} +dpy_set_ui_info(ssd->dcl.con, &info); +dprint(1, "%s/%d: size %dx%d\n", __func__, ssd->qxl.id, + info.width, info.height); +return 1; } static const QXLInterface dpy_interface = { -- 1.8.3.1
[Qemu-devel] [PULL 0/2] spice patch queue
Hi, Here comes the small spice patch queue with only two patches, one of them fixing a segfault though. please pull, Gerd The following changes since commit 0e12e61ff9a3407d123d0dbc4d945aec98d60fdf: Merge remote-tracking branch 'remotes/kraxel/tags/pull-vga-20150610-1' into staging (2015-06-10 18:13:58 +0100) are available in the git repository at: git://anongit.freedesktop.org/spice/qemu tags/pull-spice-20150611-1 for you to fetch changes up to 5a9259a0b5d6f9424f94539cd9c715b1d166d90c: spice: ui_info tweaks (2015-06-11 09:06:14 +0200) spice: fix segfault in qemu_spice_create_update, ui_info tweaks. Gerd Hoffmann (2): spice-display: fix segfault in qemu_spice_create_update spice: ui_info tweaks ui/spice-display.c | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-)
[Qemu-devel] [PULL 1/2] spice-display: fix segfault in qemu_spice_create_update
Although it is pretty unusual the stride for the guest image and the mirror image maintained by spice-display can be different. So use separate variables for them. https://bugzilla.redhat.com/show_bug.cgi?id=1163047 Cc: qemu-sta...@nongnu.org Reported-by: perrier vincent Signed-off-by: Gerd Hoffmann --- ui/spice-display.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ui/spice-display.c b/ui/spice-display.c index 9c63132..4e6356a 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -199,7 +199,7 @@ static void qemu_spice_create_update(SimpleSpiceDisplay *ssd) static const int blksize = 32; int blocks = (surface_width(ssd->ds) + blksize - 1) / blksize; int dirty_top[blocks]; -int y, yoff, x, xoff, blk, bw; +int y, yoff1, yoff2, x, xoff, blk, bw; int bpp = surface_bytes_per_pixel(ssd->ds); uint8_t *guest, *mirror; @@ -214,13 +214,14 @@ static void qemu_spice_create_update(SimpleSpiceDisplay *ssd) guest = surface_data(ssd->ds); mirror = (void *)pixman_image_get_data(ssd->mirror); for (y = ssd->dirty.top; y < ssd->dirty.bottom; y++) { -yoff = y * surface_stride(ssd->ds); +yoff1 = y * surface_stride(ssd->ds); +yoff2 = y * pixman_image_get_stride(ssd->mirror); for (x = ssd->dirty.left; x < ssd->dirty.right; x += blksize) { xoff = x * bpp; blk = x / blksize; bw = MIN(blksize, ssd->dirty.right - x); -if (memcmp(guest + yoff + xoff, - mirror + yoff + xoff, +if (memcmp(guest + yoff1 + xoff, + mirror + yoff2 + xoff, bw * bpp) == 0) { if (dirty_top[blk] != -1) { QXLRect update = { -- 1.8.3.1
Re: [Qemu-devel] [PATCH] hw/vfio/platform: replace g_malloc0_n by g_malloc0
On 2015/6/11 15:14, Eric Auger wrote: > g_malloc0_n() is introduced since glib-2.24 while QEMU currently > requires glib-2.22. This may cause a link error on some distributions. > > Signed-off-by: Eric Auger > --- > hw/vfio/platform.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c > index 35266a8..c0acc8b 100644 > --- a/hw/vfio/platform.c > +++ b/hw/vfio/platform.c > @@ -346,8 +346,7 @@ static int vfio_populate_device(VFIODevice *vbasedev) > return ret; > } > > -vdev->regions = g_malloc0_n(vbasedev->num_regions, > -sizeof(VFIORegion *)); > +vdev->regions = g_malloc0(vbasedev->num_regions * sizeof(VFIORegion *)); > Why not use g_new0() which returned pointer is cast to the given type? Regards, -Gonglei > for (i = 0; i < vbasedev->num_regions; i++) { > struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) }; >
Re: [Qemu-devel] [PATCH 0/4] PPC IBM 40p PReP emulation
Hi Hervé, On Wed, Jun 10, 2015 at 11:18 PM, Hervé Poussineau wrote: > Hi, > > This patchset adds the emulation of the IBM RS/6000 7020 (40p). Well done! Congratulations on a good job! > The real machine is > able to run AIX (up to 4.3.3), Windows NT (up to 4.0 SP1), the beta of OS/2 > PowerPC, > Solaris, Linux, NetBSD/PReP ... > I've tested current emulation with Open Firmware PReP and with official > firmware. > Patch 2 has been of a great help when using official firmware. However, if > required, > I can drop it. > > Linux kernel runs. > Windows NT starts up to the point where it wants to change endianness. > Other OSes have not been tested. Solaris would likely have the same problem: it's little-endian on PReP. > To test, download firmware a http://tyom.de/qprepofw-serial-svn-3738.rom . > Thanks Artyom! You are welcome. I see your machine is using a S3 graphic card. If you like I can add a driver for it. Not within the next days though. Out of curiosity: is the proprietary firmware also able to use a Cirrus Logic card? Regards, Artyom > Then, run: > qemu-system-ppc -M 40p -bios qprepofw-serial-svn-3738.rom -readconfig > ibm_40p.cfg -serial stdio > > Note that you can't natively boot from a hard disk using Open Firmware, as > 40p storage is SCSI. > > Hervé > > Hervé Poussineau (4): > prep: QOM'ify System I/O > prep: add RS/6000 debug device > prep: add IBM RS/6000 7020 (40p) memory controller > prep: add IBM RS/6000 7020 (40p) machine emulation > > default-configs/ppc-softmmu.mak | 4 + > docs/ibm_40p.cfg| 42 ++ > hw/ppc/Makefile.objs| 3 + > hw/ppc/prep.c | 99 + > hw/ppc/prep_systemio.c | 300 > > hw/ppc/rs6000_debug.c | 260 ++ > hw/ppc/rs6000_mc.c | 229 ++ > trace-events| 11 ++ > 8 files changed, 948 insertions(+) > create mode 100644 docs/ibm_40p.cfg > create mode 100644 hw/ppc/prep_systemio.c > create mode 100644 hw/ppc/rs6000_debug.c > create mode 100644 hw/ppc/rs6000_mc.c > > -- > 2.1.4 > -- Regards, Artyom Tarasenko SPARC and PPC PReP under qemu blog: http://tyom.blogspot.com/search/label/qemu
Re: [Qemu-devel] [SeaBIOS] qemu freeze, seabios release
On 06/11/15 09:42, Gerd Hoffmann wrote: > Hi, > > qemu soft freeze for 2.4 is just around the corner, time to think about > the seabios release which should be included there. > > A new release from master isn't even planned yet[1], so I think we > should go for a 1.8.2 stable release. So, if there are any fixes which > should be cherry-picked into stable please speak up now. So far my list > is pretty short: > > 87f848e vga: rework virtio-vga support > > cheers, > Gerd > > [1] It probably makes sense to plan once the tpm support merge > is complete. For the next master release: we've been working with Marcel on properly formatting OFW devpaths in QEMU, for the "bootorder" fw_cfg file, for booting off devices behind a PXB. Patches are on qemu-devel (meaning they should be okay for 2.4). I have patches for OVMF and Marcel is looking into SeaBIOS. So, I think support for these devpaths too should be included in the next master release of SeaBIOS. Thanks Laszlo
Re: [Qemu-devel] [PATCH] block: Change bitmap truncate conditional to assertion
Am 10.06.2015 um 22:55 hat John Snow geschrieben: > On 06/10/2015 04:52 PM, Eric Blake wrote: > > On 06/10/2015 11:24 AM, John Snow wrote: > >> Requires: 1433796555-5608-1-git-send-email-js...@redhat.com > >> [PATCH] block: record new size in bdrv_dirty_bitmap_truncate > >> > > > > Shouldn't this be after the '---' separator? > > > > Sorry, not used to sending single patches without a cover letter. > > Kevin: If it's not inconvenient for you to do, please delete these > lines on commit. No problem. > >> This is an artifact of an older version that had both all-bitmap > >> and single-bitmap truncate functions, and some info got lost in > >> the shuffle. > >> > >> Bitmaps can only be frozen during a backup operation, and a > >> backup operation should prevent a resize operation, so just > >> assert that this cannot happen. > >> > >> Suggested-by: Kevin Wolf Signed-off-by: John > >> Snow --- block.c | 4 +--- 1 file changed, 1 > >> insertion(+), 3 deletions(-) > > > > Reviewed-by: Eric Blake Thanks, applied to the block branch. Kevin pgpY7jzJxfxcP.pgp Description: PGP signature
Re: [Qemu-devel] [PATCH 00/33] virtio 1.0 patch series rebased
Hi, > Here's an incomplete todo for spec compliance: note that it does not > have to block this patchset: > - complete other devices besides net, balloon > need to disable a bunch of features > that 1.0 has deprecated So, what is the plan here? For legacy devices we keep the features, for backward compatibility reasons. For modern devices we drop the deprecated features. What about transitional? Drop them too? Implementation-wise we probably want a mask in VirtIODevice ... cheers, Gerd
Re: [Qemu-devel] [Qemu-block] [PATCH v2 0/2] block: driver should override flags in bdrv_open()
On Wed, Jun 10, 2015 at 10:37:10AM +0200, Kevin Wolf wrote: > Am 09.06.2015 um 17:21 hat Eric Blake geschrieben: > > On 06/09/2015 08:48 AM, Stefan Hajnoczi wrote: > > > I guess my @redhat.com email was received directly from Max because I > > > was in CC list. It didn't pass through Mailman. I saw the original, > > > unmodified list of CCs with Kevin included. > > > > > > The @gmail.com email was received from the mailing list. Mailman did > > > what you described. > > > > And that's what makes it so annoying. Original recipients have the full > > list, but later additions to the thread don't know who the original > > recipients were, only that including the list in reply will also reach > > the original recipients (albeit maybe not filtered into the right folder). > > > > I have no idea if mailman has some tweakable setting that can change > > this bad out-of-the-box default of munging cc's that so many lists use, > > but even if it does, it requires a list admin to tweak the setting, for > > each affected list. > > > > > > > > This means I cannot send "Please CC maintainer" emails anymore because > > > I cannot be sure whether the maintainer was CCed! > > > > Well, unless you know the maintainer is one of the people who does NOT > > use the mailman setting of "don't send me duplicate mails" (sadly, we > > have deduced that Kevin does use it, making it harder to tell if he is > > aware of a thread). > > Sorry, I wasn't aware about this behaviour. I thought I had finally > found the one use case where this option actually makes sense, but it > turns out that even if you really want the advertised thing, the option > is useless crap. > > I've fixed my mailman settings and replicated the functionality I really > want in additional email filter rules. Hope I got it right and emails > that I should see won't be disappearing... > > Please let me know if you still see me removed from CC lists. Thanks! Stefan pgpSoxISu9jFL.pgp Description: PGP signature
Re: [Qemu-devel] [PATCH v7 0/8] block: Mirror discarded sectors
On Mon, 06/08 14:02, Stefan Hajnoczi wrote: > On Mon, Jun 08, 2015 at 01:56:06PM +0800, Fam Zheng wrote: > > v7: Fix the lost assignment of s->unmap. > > > > v6: Fix pnum in bdrv_get_block_status_above. [Paolo] > > > > v5: Rewrite patch 1. > > Address Eric's comments on patch 3. > > Add Eric's rev-by to patches 2 & 4. > > Check BDRV_BLOCK_DATA in patch 3. [Paolo] > > > > This fixes the mirror assert failure reported by wangxiaolong: > > > > https://lists.gnu.org/archive/html/qemu-devel/2015-04/msg04458.html > > > > The direct cause is that hbitmap code couldn't handle unset of bits *after* > > iterator's current position. We could fix that, but the bdrv_reset_dirty() > > call > > is more questionable: > > > > Before, if guest discarded some sectors during migration, it could see > > different data after moving to dest side, depending on block backends of the > > src and the dest. This is IMO worse than mirroring the actual reading as > > done > > in this series, because we don't know what the guest is doing. > > > > For example if a guest first issues WRITE SAME to wipe out the area then > > issues > > UNMAP to discard it, just to get rid of some sensitive data completely, we > > may > > miss both operations and leave stale data on dest image. > > > > > > Fam Zheng (8): > > block: Add bdrv_get_block_status_above > > qmp: Add optional bool "unmap" to drive-mirror > > mirror: Do zero write on target if sectors not allocated > > block: Fix dirty bitmap in bdrv_co_discard > > block: Remove bdrv_reset_dirty > > qemu-iotests: Make block job methods common > > qemu-iotests: Add test case for mirror with unmap > > iotests: Use event_wait in wait_ready > > > > block.c | 12 > > block/io.c| 60 ++- > > block/mirror.c| 28 +++--- > > blockdev.c| 5 > > hmp.c | 2 +- > > include/block/block.h | 4 +++ > > include/block/block_int.h | 4 +-- > > qapi/block-core.json | 8 +- > > qmp-commands.hx | 3 ++ > > tests/qemu-iotests/041| 66 > > ++- > > tests/qemu-iotests/132| 59 ++ > > tests/qemu-iotests/132.out| 5 > > tests/qemu-iotests/group | 1 + > > tests/qemu-iotests/iotests.py | 23 +++ > > 14 files changed, 196 insertions(+), 84 deletions(-) > > create mode 100644 tests/qemu-iotests/132 > > create mode 100644 tests/qemu-iotests/132.out > > > > -- > > 2.4.2 > > > > Thanks, applied to my block tree: > https://github.com/stefanha/qemu/commits/block Stefan, The only controversial patches are the qmp/drive-mirror ones (1-3), while patches 4-8 are still useful on their own: they fix the mentioned crash and improve iotests. Shall we merge the second half (of course none of them depend on 1-3) now that softfreeze is approaching? Fam
Re: [Qemu-devel] [PATCH 6/8] qcow2: add autoclear bit for dirty bitmaps
Am 11.06.2015 um 01:42 hat John Snow geschrieben: > > > On 06/08/2015 11:21 AM, Vladimir Sementsov-Ogievskiy wrote: > > From: Vladimir Sementsov-Ogievskiy > > > > Signed-off-by: Vladimir Sementsov-Ogievskiy > > --- > > block/qcow2-dirty-bitmap.c | 5 + > > block/qcow2.c | 13 +++-- > > block/qcow2.h | 9 + > > 3 files changed, 25 insertions(+), 2 deletions(-) > > > > diff --git a/block/qcow2-dirty-bitmap.c b/block/qcow2-dirty-bitmap.c > > index db83112..686a121 100644 > > --- a/block/qcow2-dirty-bitmap.c > > +++ b/block/qcow2-dirty-bitmap.c > > @@ -188,6 +188,11 @@ static int qcow2_write_dirty_bitmaps(BlockDriverState > > *bs) > > > > s->dirty_bitmaps_offset = dirty_bitmaps_offset; > > s->dirty_bitmaps_size = dirty_bitmaps_size; > > +if (s->nb_dirty_bitmaps > 0) { > > +s->autoclear_features |= QCOW2_AUTOCLEAR_DIRTY_BITMAPS; > > +} else { > > +s->autoclear_features &= ~QCOW2_AUTOCLEAR_DIRTY_BITMAPS; > > +} > > ret = qcow2_update_header(bs); > > if (ret < 0) { > > fprintf(stderr, "Could not update qcow2 header\n"); > > diff --git a/block/qcow2.c b/block/qcow2.c > > index 406e55d..f85a55a 100644 > > --- a/block/qcow2.c > > +++ b/block/qcow2.c > > @@ -182,6 +182,14 @@ static int qcow2_read_extensions(BlockDriverState *bs, > > uint64_t start_offset, > > return ret; > > } > > > > +if (!(s->autoclear_features & QCOW2_AUTOCLEAR_DIRTY_BITMAPS) && > > +s->nb_dirty_bitmaps > 0) { > > +ret = qcow2_delete_all_dirty_bitmaps(bs, errp); > > +if (ret < 0) { > > +return ret; > > +} > > +} > > + > > #ifdef DEBUG_EXT > > printf("Qcow2: Got dirty bitmaps extension:" > > " offset=%" PRIu64 " nb_bitmaps=%" PRIu32 "\n", > > @@ -928,8 +936,9 @@ static int qcow2_open(BlockDriverState *bs, QDict > > *options, int flags, > > } > > > > /* Clear unknown autoclear feature bits */ > > -if (!bs->read_only && !(flags & BDRV_O_INCOMING) && > > s->autoclear_features) { > > -s->autoclear_features = 0; > > +if (!bs->read_only && !(flags & BDRV_O_INCOMING) && > > +(s->autoclear_features & ~QCOW2_AUTOCLEAR_MASK)) { > > +s->autoclear_features |= QCOW2_AUTOCLEAR_MASK; > > Like Stefan already mentioned, fixing this |= to &= will fix iotest 036, > which is otherwise broken by this patch. > > > ret = qcow2_update_header(bs); > > if (ret < 0) { > > error_setg_errno(errp, -ret, "Could not update qcow2 header"); > > diff --git a/block/qcow2.h b/block/qcow2.h > > index b5e576c..14bd6f9 100644 > > --- a/block/qcow2.h > > +++ b/block/qcow2.h > > @@ -215,6 +215,15 @@ enum { > > QCOW2_COMPAT_FEAT_MASK= QCOW2_COMPAT_LAZY_REFCOUNTS, > > }; > > > > +/* Autoclear feature bits */ > > +enum { > > +QCOW2_AUTOCLEAR_DIRTY_BITMAPS_BITNR = 0, > > +QCOW2_AUTOCLEAR_DIRTY_BITMAPS = > > +1 << QCOW2_AUTOCLEAR_DIRTY_BITMAPS_BITNR, > > + > > +QCOW2_AUTOCLEAR_MASK= QCOW2_AUTOCLEAR_DIRTY_BITMAPS, > > +}; > > + > > I find it a little awkward to have an enum with three different kinds of > data in it, unless I am reading this incorrectly. (bit position, bit > masks, and accumulated bit mask.) This is only consistent with the enums for incompatible and compatible feature flags. If we were to change that, we should change it everywhere. > Just enumerating the indices is probably sufficient: > > enum { > QCOW2_AUTOCLEAR_BEGIN = 0, > QCOW2_AUTOCLEAR_DIRTY_BITMAPS = QCOW2_AUTOCLEAR_BEGIN, > ..., > QCOW2_AUTOCLEAR_END > } I don't mind the colour of the bikeshed, as long as all constants are explicitly defined. Letting the compiler assign integers when these integers are part of an external interface is too easy to break accidentally. Kevin
[Qemu-devel] [PULL 0/1] sdl patch queue
Hi, Single fix patch queue for sdl. please pull, Gerd The following changes since commit ee09f84e6bf5383a23c9624115c26b72aa1e076c: Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2015-06-08 15:57:41 +0100) are available in the git repository at: git://git.kraxel.org/qemu tags/pull-sdl-20150611-1 for you to fetch changes up to 08d49df0dbaacc220a099dbfb644e1dc0eda57be: sdl2: fix crash in handle_windowevent() when restoring the screen size (2015-06-09 10:25:21 +0200) sdl2: fix crash in handle_windowevent() when restoring the screen size Alberto Garcia (1): sdl2: fix crash in handle_windowevent() when restoring the screen size ui/sdl2.c | 4 1 file changed, 4 insertions(+)
[Qemu-devel] [PULL 1/1] sdl2: fix crash in handle_windowevent() when restoring the screen size
From: Alberto Garcia The Ctrl-Alt-u keyboard shortcut restores the screen to its original size. In the SDL2 UI this is done by destroying the window and creating a new one. The old window emits SDL_WINDOWEVENT_HIDDEN when it's destroyed, but trying to call SDL_GetWindowFromID() from that event's window ID returns a null pointer. handle_windowevent() assumes that the pointer is never null so it results in a crash. Cc: qemu-sta...@nongnu.org Signed-off-by: Alberto Garcia Signed-off-by: Gerd Hoffmann --- ui/sdl2.c | 4 1 file changed, 4 insertions(+) diff --git a/ui/sdl2.c b/ui/sdl2.c index 2d60179..5cb75aa 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -521,6 +521,10 @@ static void handle_windowevent(SDL_Event *ev) { struct sdl2_console *scon = get_scon_from_window(ev->window.windowID); +if (!scon) { +return; +} + switch (ev->window.event) { case SDL_WINDOWEVENT_RESIZED: { -- 1.8.3.1
Re: [Qemu-devel] [PATCH v2 0/2] Makefile: Generate tag files under $SRC_PATH
On Fri, 05/22 13:35, Fam Zheng wrote: Ping :) Fam > > > Fam Zheng (2): > Makefile: Fix "make cscope TAGS" > Makefile: Add "make ctags" > > Makefile | 20 +++- > 1 file changed, 15 insertions(+), 5 deletions(-) > > -- > 2.4.1 > >
[Qemu-devel] [PATCH v2] hw/vfio/platform: replace g_malloc0_n by g_new0
g_malloc0_n() is introduced since glib-2.24 while QEMU currently requires glib-2.22. This may cause a link error on some distributions. Signed-off-by: Eric Auger --- v1 -> v2: - replace g_malloc0 by g_new0 --- hw/vfio/platform.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index 35266a8..9382bb7 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -346,8 +346,7 @@ static int vfio_populate_device(VFIODevice *vbasedev) return ret; } -vdev->regions = g_malloc0_n(vbasedev->num_regions, -sizeof(VFIORegion *)); +vdev->regions = g_new0(VFIORegion *, vbasedev->num_regions); for (i = 0; i < vbasedev->num_regions; i++) { struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) }; -- 1.8.3.2
Re: [Qemu-devel] [PATCH] hw/vfio/platform: replace g_malloc0_n by g_malloc0
Hi Gonglei, On 06/11/2015 09:55 AM, Gonglei wrote: > On 2015/6/11 15:14, Eric Auger wrote: >> g_malloc0_n() is introduced since glib-2.24 while QEMU currently >> requires glib-2.22. This may cause a link error on some distributions. >> >> Signed-off-by: Eric Auger >> --- >> hw/vfio/platform.c | 3 +-- >> 1 file changed, 1 insertion(+), 2 deletions(-) >> >> diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c >> index 35266a8..c0acc8b 100644 >> --- a/hw/vfio/platform.c >> +++ b/hw/vfio/platform.c >> @@ -346,8 +346,7 @@ static int vfio_populate_device(VFIODevice *vbasedev) >> return ret; >> } >> >> -vdev->regions = g_malloc0_n(vbasedev->num_regions, >> -sizeof(VFIORegion *)); >> +vdev->regions = g_malloc0(vbasedev->num_regions * sizeof(VFIORegion *)); >> > > Why not use g_new0() which returned pointer is cast to the given type? Looks relevant indeed. g_malloc0 is used in similar situations in rest of the VFIO code so I posted a new version and let Alex choose among both. Thanks Eric > > Regards, > -Gonglei >> for (i = 0; i < vbasedev->num_regions; i++) { >> struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) }; >> > >
Re: [Qemu-devel] [PULL v2 1/3] hw/vfio/platform: vfio-platform skeleton
On 11 June 2015 at 03:21, Gonglei wrote: > Failed to build on SUSE11.3: > That's because g_malloc0_n() introduced since glib-2.24, > but QEMU just require glib-2.22. Thanks for the catch -- I do have a glib-2.22 system in my pre-pull build tests, but it's not x86/Linux, so it won't try to compile the vfio code, which is why it missed this. -- PMM
Re: [Qemu-devel] PING: RE: [PATCH RFC V3 1/4] Use Aff1 with mpidr This is an improved and KVM-aware alternative to
On 11 June 2015 at 08:46, Pavel Fedin wrote: > Hi Peter! > >> Hi. I think this patch largely makes sense, but I have some comments >> below. If you want to fix these and resend as a standalone patch >> I'm happy to apply that. > > How are things going? I have resent v4 of this on the very same day, > and got no reaction from you since then. It's on my to-review list, but you only sent it three days ago. PS: if you send your "ping" mails as actual follow ups to the ptach you're pinging and don't change the Subject line, then I will be able to find the patch you're referring to much more easily. For me this email does not appear threaded into the conversation on the patch mail... thanks -- PMM
Re: [Qemu-devel] [PATCH v3 0/3] Support more than 8 MMU modes, speedup PPC by 10%
Hi Paolo, On Tue, May 5, 2015 at 9:18 AM, Paolo Bonzini wrote: > Patches 1 and 2 enable support from more than 8 MMU modes in TCG (patch > 1 is in the targets, patch 2 is in cpu-defs.h). The TLB size is reduced > proportionally on targets where that is necessary. This is a very promising approach. Would it also work on a large numbers of MMU modes? Particulary I wonder if it would work for SPARC, where 32-bit processors have up to 65536 MMU contexts. Regards, Artyom > Patch 3 uses the new support in the PPC target. > > Paolo > > v2->v3: - change i386 TCG_TARGET_TLB_DISPLACEMENT_BITS to 31 [rth] > - tweak comment in patch 2 to account for > offsetof(CPUArchState, tlb_table[mem_index][0].addend) [rth] > > > Paolo Bonzini (3): > tcg: add TCG_TARGET_TLB_DISPLACEMENT_BITS > softmmu: support up to 12 MMU modes > target-ppc: use separate indices for various translation modes > > include/exec/cpu-defs.h | 34 +++- > include/exec/cpu_ldst.h | 104 > --- > target-ppc/cpu.h | 12 +++--- > target-ppc/excp_helper.c | 3 -- > target-ppc/helper_regs.h | 15 --- > tcg/aarch64/tcg-target.h | 1 + > tcg/arm/tcg-target.h | 1 + > tcg/i386/tcg-target.h| 1 + > tcg/ia64/tcg-target.h| 2 + > tcg/mips/tcg-target.h| 1 + > tcg/ppc/tcg-target.h | 1 + > tcg/s390/tcg-target.h| 1 + > tcg/sparc/tcg-target.h | 1 + > tcg/tci/tcg-target.h | 1 + > 14 files changed, 156 insertions(+), 22 deletions(-) > > -- > 2.3.5 > > -- Regards, Artyom Tarasenko SPARC and PPC PReP under qemu blog: http://tyom.blogspot.com/search/label/qemu
Re: [Qemu-devel] [PATCH v3 4/6] hw/core: rebase sysbus_get_fw_dev_path() to g_strdup_printf()
On 06/11/2015 03:38 AM, Laszlo Ersek wrote: Cc: Markus Armbruster Cc: Marcel Apfelbaum Cc: Michael S. Tsirkin Signed-off-by: Laszlo Ersek --- Notes: v3: - new in v3 hw/core/sysbus.c | 16 ++-- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index b53c351..0ebb4e2 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -281,19 +281,15 @@ static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent) static char *sysbus_get_fw_dev_path(DeviceState *dev) { SysBusDevice *s = SYS_BUS_DEVICE(dev); -char path[40]; -int off; - -off = snprintf(path, sizeof(path), "%s", qdev_fw_name(dev)); if (s->num_mmio) { -snprintf(path + off, sizeof(path) - off, "@"TARGET_FMT_plx, - s->mmio[0].addr); -} else if (s->num_pio) { -snprintf(path + off, sizeof(path) - off, "@i%04x", s->pio[0]); +return g_strdup_printf("%s@"TARGET_FMT_plx, qdev_fw_name(dev), + s->mmio[0].addr); } - -return g_strdup(path); +if (s->num_pio) { +return g_strdup_printf("%s@i%04x", qdev_fw_name(dev), s->pio[0]); +} +return g_strdup(qdev_fw_name(dev)); } void sysbus_add_io(SysBusDevice *dev, hwaddr addr, Reviewed-by: Marcel Apfelbaum
Re: [Qemu-devel] [PATCH v3 5/6] hw/core: explicit OFW unit address property for SysBusDevice
On 06/11/2015 03:38 AM, Laszlo Ersek wrote: The sysbus_get_fw_dev_path() function formats OpenFirmware device path nodes ("driver-name@unit-address") for sysbus devices. The first choice for "unit-address" is the base address of the device's first MMIO region. The second choice is its first IO port. However, if two sysbus devices with the same "driver-name" lack both MMIO and PIO resources, then there is no good way to distinguish them based on their OFW nodes, because in this case unit-address is omitted completely for both devices. For such devices, delegate a fallback property, "explicit_ofw_unit_address", to whoever creates the device. The creator can set the property to any appropriate value. Cc: Markus Armbruster Cc: Marcel Apfelbaum Cc: Michael S. Tsirkin Signed-off-by: Laszlo Ersek --- Notes: v3: - new in v3 - new approach include/hw/sysbus.h | 8 hw/core/sysbus.c| 11 +++ 2 files changed, 19 insertions(+) diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h index d1f3f00..de41b06 100644 --- a/include/hw/sysbus.h +++ b/include/hw/sysbus.h @@ -55,6 +55,14 @@ struct SysBusDevice { } mmio[QDEV_MAX_MMIO]; int num_pio; pio_addr_t pio[QDEV_MAX_PIO]; + +/* + * Sometimes a SysBusDevice has neither MMIO nor PIO resources, yet it + * would like to distinguish itself, in OpenFirmware device paths, from + * other instances of the same class on the same sysbus. For that end we + * expose this property. + */ +char *explicit_ofw_unit_address; }; typedef int FindSysbusDeviceFunc(SysBusDevice *sbdev, void *opaque); diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index 0ebb4e2..6e9af1c 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -289,6 +289,10 @@ static char *sysbus_get_fw_dev_path(DeviceState *dev) if (s->num_pio) { return g_strdup_printf("%s@i%04x", qdev_fw_name(dev), s->pio[0]); } +if (s->explicit_ofw_unit_address) { +return g_strdup_printf("%s@%s", qdev_fw_name(dev), + s->explicit_ofw_unit_address); +} return g_strdup(qdev_fw_name(dev)); } @@ -303,11 +307,18 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev) return get_system_memory(); } +static Property sysbus_device_properties[] = { +DEFINE_PROP_STRING("explicit_ofw_unit_address", SysBusDevice, + explicit_ofw_unit_address), +DEFINE_PROP_END_OF_LIST() +}; + static void sysbus_device_class_init(ObjectClass *klass, void *data) { DeviceClass *k = DEVICE_CLASS(klass); k->init = sysbus_device_init; k->bus_type = TYPE_SYSTEM_BUS; +k->props = sysbus_device_properties; } static const TypeInfo sysbus_device_type_info = { Better than previous approach. Reviewed-by: Marcel Apfelbaum
Re: [Qemu-devel] [PATCH v3 6/6] hw/pci-bridge: set explicit OFW unit address for TYPE_PXB_HOST
On 06/11/2015 03:38 AM, Laszlo Ersek wrote: The PXB implementation doesn't allow firmware (SeaBIOS or OVMF) to boot off devices behind the PXB. This happens because the sysbus_get_fw_dev_path() function in "hw/core/sysbus.c" doesn't have enough information to format a unique identifier for the PXB in question, and consequently the OpenFirmware device path passed down to the guest firmware in the "bootorder" fw_cfg file is unusable for identifying the boot device. For example, the command line fragment -device pxb,id=bridge1,bus_nr=4 \ \ -netdev user,id=netdev0 \ -device e1000,netdev=netdev0,bus=bridge1,addr=2,bootindex=0 results in the following "bootorder" entry: /pci/pci-bridge@0/ethernet@2/ethernet-phy@0 The initial "pci" node is formatted by sysbus_get_fw_dev_path(), and the resultant OpenFirmware device path is independent of bus_nr=4 -- and therefore it is useless for identifying the device. In this patch we change the fw_name device class member of TYPE_PXB_HOST from "pci" to "pci-root", and set each instance's explicit OFW unit address to the PXB bus number. The same command line fragment results in the following OpenFirmware device path in the "bootorder" fw_cfg file: /pci-root@4/pci-bridge@0/ethernet@2/ethernet-phy@0 Clean The original, initial "/pci" fragment has been replaced with "/pci-root@4", which (a) looks better, (b) provides all the necessary information. Cc: Markus Armbruster Cc: Marcel Apfelbaum Cc: Michael S. Tsirkin Signed-off-by: Laszlo Ersek --- Notes: v3: - using new sysbus device property, not inserting additional bus hw/pci-bridge/pci_expander_bridge.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c index c7a085d..d468670 100644 --- a/hw/pci-bridge/pci_expander_bridge.c +++ b/hw/pci-bridge/pci_expander_bridge.c @@ -93,7 +93,7 @@ static void pxb_host_class_init(ObjectClass *class, void *data) DeviceClass *dc = DEVICE_CLASS(class); PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(class); -dc->fw_name = "pci"; +dc->fw_name = "pci-root"; hc->root_bus_path = pxb_host_root_bus_path; } @@ -152,6 +152,7 @@ static int pxb_dev_initfn(PCIDevice *dev) { PXBDev *pxb = PXB_DEV(dev); DeviceState *ds, *bds; +char *bus_nr_str; PCIBus *bus; const char *dev_name = NULL; @@ -166,6 +167,10 @@ static int pxb_dev_initfn(PCIDevice *dev) } ds = qdev_create(NULL, TYPE_PXB_HOST); +bus_nr_str = g_strdup_printf("%x", pxb->bus_nr); +qdev_prop_set_string(ds, "explicit_ofw_unit_address", bus_nr_str); +g_free(bus_nr_str); This is the best approach yet. I think it will not affect migration, because on the target site it will have the same bus number, so the property doesn't need to be passed. Is my time to see how it will work on Seabios. Thanks a lot for your help!! Reviewed-by: Marcel Apfelbaum + bus = pci_bus_new(ds, "pxb-internal", NULL, NULL, 0, TYPE_PXB_BUS); bus->parent_dev = dev;
[Qemu-devel] virt-test broken by 'gtk: add opengl support, using egl' 97edf3bd5
Hi, I've just bisected a virt-test breakage down to: 97edf3bd5 'gtk: add opengl support, using egl' I think the problem is that it's trying to start X up early on, even in the cases when qemu would just print some help and exit. I'm running virt-test on a remote machine via ssh and don't have DISPLAY set. Symptom --- Virt-test run of migrate.default.tcp is marked as 'SKIP' The debug logs show: TestNAError: usb controller ich9-usb-uhci1 not available Bisect: GOOD 2.3.0 fresh iconfigure GOOD 4d2d2d8 GOOD a308817743be5cc051d3379477f54027deb0befb GOOD 922cc8823e484733021a7be5b0e876eba2218623 GOOD 9441aa282bc3213ef0530cab86f318b877bac25c GOOD 7ced9e9f6da2257224591b91727cfeee4f3977fb BAD 97edf3bd5eab8952d475de66ede77307c12b8c48 BAD 63c67b6d4462b6589b371d55e3740e9f0dba3281 BAD 2a90c454a1b90ace56ed908cd064f2fd483d1231 BAD 39b87c7 BAD 13644819c5bf322ae4c2a415aca77d5dbde95fe8 BAD 6fa6b312765f698dc81b 97edf3bd5eab8952d475de66ede77307c12b8c48 is the first bad commit commit 97edf3bd5eab8952d475de66ede77307c12b8c48 Author: Gerd Hoffmann Date: Tue Jan 20 12:43:28 2015 +0100 gtk: add opengl support, using egl Virt-test at startup runs qemu -device ? to get a list of devices; on older versions that gives me the list and exit's with $?=0 on 973ef3 it does: [root@virtlab403 virt-test]# /root/try/bin/qemu-system-x86_64 -device '?' (qemu-system-x86_64:5192): Gtk-WARNING **: cannot open display: (Test environment is RHEL7.1ish) Dave -- Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK
Re: [Qemu-devel] [PATCH v3 6/6] hw/pci-bridge: set explicit OFW unit address for TYPE_PXB_HOST
On 06/11/15 11:15, Marcel Apfelbaum wrote: > On 06/11/2015 03:38 AM, Laszlo Ersek wrote: >> The PXB implementation doesn't allow firmware (SeaBIOS or OVMF) to boot >> off devices behind the PXB. This happens because the >> sysbus_get_fw_dev_path() function in "hw/core/sysbus.c" doesn't have >> enough information to format a unique identifier for the PXB in question, >> and consequently the OpenFirmware device path passed down to the guest >> firmware in the "bootorder" fw_cfg file is unusable for identifying the >> boot device. >> >> For example, the command line fragment >> >>-device pxb,id=bridge1,bus_nr=4 \ >>\ >>-netdev user,id=netdev0 \ >>-device e1000,netdev=netdev0,bus=bridge1,addr=2,bootindex=0 >> >> results in the following "bootorder" entry: >> >>/pci/pci-bridge@0/ethernet@2/ethernet-phy@0 >> >> The initial "pci" node is formatted by sysbus_get_fw_dev_path(), and the >> resultant OpenFirmware device path is independent of bus_nr=4 -- and >> therefore it is useless for identifying the device. >> >> In this patch we change the fw_name device class member of TYPE_PXB_HOST >> from "pci" to "pci-root", and set each instance's explicit OFW unit >> address to the PXB bus number. The same command line fragment results in >> the following OpenFirmware device path in the "bootorder" fw_cfg file: >> >>/pci-root@4/pci-bridge@0/ethernet@2/ethernet-phy@0 > Clean > >> >> The original, initial "/pci" fragment has been replaced with >> "/pci-root@4", which (a) looks better, (b) provides all the necessary >> information. >> >> Cc: Markus Armbruster >> Cc: Marcel Apfelbaum >> Cc: Michael S. Tsirkin >> Signed-off-by: Laszlo Ersek >> --- >> >> Notes: >> v3: >> - using new sysbus device property, not inserting additional bus >> >> hw/pci-bridge/pci_expander_bridge.c | 7 ++- >> 1 file changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/hw/pci-bridge/pci_expander_bridge.c >> b/hw/pci-bridge/pci_expander_bridge.c >> index c7a085d..d468670 100644 >> --- a/hw/pci-bridge/pci_expander_bridge.c >> +++ b/hw/pci-bridge/pci_expander_bridge.c >> @@ -93,7 +93,7 @@ static void pxb_host_class_init(ObjectClass *class, >> void *data) >> DeviceClass *dc = DEVICE_CLASS(class); >> PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(class); >> >> -dc->fw_name = "pci"; >> +dc->fw_name = "pci-root"; >> hc->root_bus_path = pxb_host_root_bus_path; >> } >> >> @@ -152,6 +152,7 @@ static int pxb_dev_initfn(PCIDevice *dev) >> { >> PXBDev *pxb = PXB_DEV(dev); >> DeviceState *ds, *bds; >> +char *bus_nr_str; >> PCIBus *bus; >> const char *dev_name = NULL; >> >> @@ -166,6 +167,10 @@ static int pxb_dev_initfn(PCIDevice *dev) >> } >> >> ds = qdev_create(NULL, TYPE_PXB_HOST); >> +bus_nr_str = g_strdup_printf("%x", pxb->bus_nr); >> +qdev_prop_set_string(ds, "explicit_ofw_unit_address", bus_nr_str); >> +g_free(bus_nr_str); > > This is the best approach yet. > I think it will not affect migration, because on the target site > it will have the same bus number, so the property doesn't need to be > passed. Yes, I thought the same. Migration should carry guest-alterable state. If, in some device, "explicit_ofw_unit_address" will ever be changed due to guest actions (as opposed to deriving it from a constant on the command line, which management would sync anyway), then that specific device will have to migrate the underlying state as it sees fit, and update the property in a post load callback. > > Is my time to see how it will work on Seabios. > Thanks a lot for your help!! > > Reviewed-by: Marcel Apfelbaum Thanks! I hope to hear back from Michael and Markus as well. Until then, this should suffice to work on the firmware(s). Laszlo >> + >> bus = pci_bus_new(ds, "pxb-internal", NULL, NULL, 0, TYPE_PXB_BUS); >> >> bus->parent_dev = dev; >> >
[Qemu-devel] [PULL 1/1] gtk: don't exit early in case gtk init fails
Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel P. Berrange --- ui/gtk.c | 13 - 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ui/gtk.c b/ui/gtk.c index 126326a..df2a79e 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1917,12 +1917,19 @@ static void gd_set_keycode_type(GtkDisplayState *s) #endif } +static gboolean gtkinit; + void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover) { GtkDisplayState *s = g_malloc0(sizeof(*s)); char *filename; GdkDisplay *window_display; +if (!gtkinit) { +fprintf(stderr, "gtk initialization failed\n"); +exit(1); +} + s->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); #if GTK_CHECK_VERSION(3, 2, 0) s->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); @@ -2003,7 +2010,11 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover) void early_gtk_display_init(int opengl) { -gtk_init(NULL, NULL); +gtkinit = gtk_init_check(NULL, NULL); +if (!gtkinit) { +/* don't exit yet, that'll break -help */ +return; +} switch (opengl) { case -1: /* default */ -- 1.8.3.1
[Qemu-devel] [PULL 0/1] gtk patch queue
Hi, gtk patch queue featuring a single bugfix. please pull, Gerd The following changes since commit 0e12e61ff9a3407d123d0dbc4d945aec98d60fdf: Merge remote-tracking branch 'remotes/kraxel/tags/pull-vga-20150610-1' into staging (2015-06-10 18:13:58 +0100) are available in the git repository at: git://git.kraxel.org/qemu tags/pull-gtk-20150611-1 for you to fetch changes up to 060ab76356fff6a420bc881a574c40a5dda086af: gtk: don't exit early in case gtk init fails (2015-06-11 11:37:56 +0200) gtk: don't exit early in case gtk init fails Gerd Hoffmann (1): gtk: don't exit early in case gtk init fails ui/gtk.c | 13 - 1 file changed, 12 insertions(+), 1 deletion(-)
Re: [Qemu-devel] [PATCH v2] RFC: qxl: allow to specify head limit to qxl driver
On Do, 2015-06-11 at 10:38 +0100, Frediano Ziglio wrote: > libvirt has this as a video card parameter (actually set to 1 but not > used). This parameter will allow to limit setting a use can do (which > could be confusing). Hmm. So heads is '1' by default but ignored today. When this starts to be actually applied that will break existing multihead setups I suspect. > This patch rely on some change in spice-protocol which are not still > accepted. See > http://lists.freedesktop.org/archives/spice-devel/2015-June/020221.html. Spice-server changes, right? Needs #ifdefs so qemu continues to build with old spice-server versions. The spice-server changes need to be upstream first. Also: when we pass on the limit to spice-server anyway spice-server can take care to apply the limit both ways and not call the ->client_monitors_config() callback with more than $limit monitors. Has the advantage to reduce the test matrix: Limit either works or doesn't. There will be no spice-server/qemu version combination where the limit is applied one way only. Gerd
Re: [Qemu-devel] [PATCH 1/8] spec: add qcow2-dirty-bitmaps specification
On 10.06.2015 16:00, Eric Blake wrote: On 06/10/2015 02:19 AM, Vladimir Sementsov-Ogievskiy wrote: +Dirty bitmaps is an optional header extension. It provides a possibility of +storing dirty bitmaps in qcow2 image. The fields are: + + 0 - 3: nb_dirty_bitmaps + Number of dirty bitmaps contained in the image Is there a maximum? hmm. any proposals for this? + + 4 - 11: dirty_bitmaps_offset I'm not sure if there is a reasonable cap on the number of dirty bitmaps; I doubt that anyone will actually supply all 4G possible images allowed by the four-byte field, but don't have a suggestion on a smaller limit that doesn't feel arbitrary. [meta-comment] It's very hard to pick out the new content in your reply if you do not separate your new text with a newline both before and after (as I'm doing here). +Dirty bitmaps are stored using a ONE-level structure for the mapping of +bitmaps to host clusters. There is only an L1 table. + +The L1 table has a variable size (stored in the Bitmap table entry) and may +use multiple clusters, however it must be contiguous in the image file. The use of "L1 table" could be confusing. The refcount metadata uses "refcount table" and "refcount block" to describe a one-level table. I agree. Hmm.. dirty bitmaps table? ok? "dirty bitmaps table" works for me, as a name for the one-level table. for now, dirty bitmaps table is the table with bitmap descriptors, and each bitmap descriptor contains its own l1 table.. What about dirty bitmap directory for descriptors and dirty bitmap table for l1? like pde pte) -- Best regards, Vladimir * now, @virtuozzo.com instead of @parallels.com. Sorry for this inconvenience.
Re: [Qemu-devel] [PATCH 1/8] spec: add qcow2-dirty-bitmaps specification
On 10.06.2015 16:24, Stefan Hajnoczi wrote: On Wed, Jun 10, 2015 at 11:19:30AM +0300, Vladimir Sementsov-Ogievskiy wrote: On 09.06.2015 20:03, Stefan Hajnoczi wrote: On Mon, Jun 08, 2015 at 06:21:19PM +0300, Vladimir Sementsov-Ogievskiy wrote: @@ -166,6 +167,19 @@ the header extension data. Each entry look like this: terminated if it has full length) +== Dirty bitmaps == + +Dirty bitmaps is an optional header extension. It provides a possibility of +storing dirty bitmaps in qcow2 image. The fields are: + + 0 - 3: nb_dirty_bitmaps + Number of dirty bitmaps contained in the image Is there a maximum? hmm. any proposals for this? 65535 seems practical. So, you suggest to reduce this field width to 2b? And additional 2 bytes reserved field, to achieve 8b-alignment? +=== Cluster mapping === + +Dirty bitmaps are stored using a ONE-level structure for the mapping of +bitmaps to host clusters. There is only an L1 table. + +The L1 table has a variable size (stored in the Bitmap table entry) and may +use multiple clusters, however it must be contiguous in the image file. The use of "L1 table" could be confusing. The refcount metadata uses "refcount table" and "refcount block" to describe a one-level table. I agree. Hmm.. dirty bitmaps table? ok? Yes, that is good. + +Given an offset into the bitmap, the offset into the image file can be +obtained as follows: + +offset = l1_table[offset / cluster_size] + (offset % cluster_size) It might help to add granularity to this formula. Instead of "offset", "bit_number" or "bitnr" might be clearer since "offset" means something different in other parts of the document. Hmm. In my opinion, the bitmap here is stored as raw data. And granularity is an additional parameter (for deserializing this data). So, it is an offset in bytes for this data. The format is not for accessing bitmap bits, it's only for loading the whole bitmap one time. You are right, it wasn't clear when I read this the first time. My problem was the "offset into the bitmap" doesn't have any units. So let's make this more explicit. Can you document how to go from a bit number down to the offset? -- Best regards, Vladimir * now, @virtuozzo.com instead of @parallels.com. Sorry for this inconvenience.
Re: [Qemu-devel] [PATCH v3 6/6] hw/pci-bridge: set explicit OFW unit address for TYPE_PXB_HOST
On 06/11/2015 03:38 AM, Laszlo Ersek wrote: The PXB implementation doesn't allow firmware (SeaBIOS or OVMF) to boot off devices behind the PXB. This happens because the sysbus_get_fw_dev_path() function in "hw/core/sysbus.c" doesn't have enough information to format a unique identifier for the PXB in question, and consequently the OpenFirmware device path passed down to the guest firmware in the "bootorder" fw_cfg file is unusable for identifying the boot device. For example, the command line fragment -device pxb,id=bridge1,bus_nr=4 \ \ -netdev user,id=netdev0 \ -device e1000,netdev=netdev0,bus=bridge1,addr=2,bootindex=0 results in the following "bootorder" entry: /pci/pci-bridge@0/ethernet@2/ethernet-phy@0 The initial "pci" node is formatted by sysbus_get_fw_dev_path(), and the resultant OpenFirmware device path is independent of bus_nr=4 -- and therefore it is useless for identifying the device. In this patch we change the fw_name device class member of TYPE_PXB_HOST from "pci" to "pci-root", and set each instance's explicit OFW unit address to the PXB bus number. The same command line fragment results in the following OpenFirmware device path in the "bootorder" fw_cfg file: /pci-root@4/pci-bridge@0/ethernet@2/ethernet-phy@0 Hi Laszlo, I applied your patches but I still get /pci@i0cf8/ethernet@5/ethernet-phy@0 in the boot list I checked and the code enters only once in sysbus_get_fw_dev_path for pci@i0cf8 and goes for pio branch. Do you know maybe what I missed? Thanks, Marcel The original, initial "/pci" fragment has been replaced with "/pci-root@4", which (a) looks better, (b) provides all the necessary information. Cc: Markus Armbruster Cc: Marcel Apfelbaum Cc: Michael S. Tsirkin Signed-off-by: Laszlo Ersek --- Notes: v3: - using new sysbus device property, not inserting additional bus hw/pci-bridge/pci_expander_bridge.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c index c7a085d..d468670 100644 --- a/hw/pci-bridge/pci_expander_bridge.c +++ b/hw/pci-bridge/pci_expander_bridge.c @@ -93,7 +93,7 @@ static void pxb_host_class_init(ObjectClass *class, void *data) DeviceClass *dc = DEVICE_CLASS(class); PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(class); -dc->fw_name = "pci"; +dc->fw_name = "pci-root"; hc->root_bus_path = pxb_host_root_bus_path; } @@ -152,6 +152,7 @@ static int pxb_dev_initfn(PCIDevice *dev) { PXBDev *pxb = PXB_DEV(dev); DeviceState *ds, *bds; +char *bus_nr_str; PCIBus *bus; const char *dev_name = NULL; @@ -166,6 +167,10 @@ static int pxb_dev_initfn(PCIDevice *dev) } ds = qdev_create(NULL, TYPE_PXB_HOST); +bus_nr_str = g_strdup_printf("%x", pxb->bus_nr); +qdev_prop_set_string(ds, "explicit_ofw_unit_address", bus_nr_str); +g_free(bus_nr_str); + bus = pci_bus_new(ds, "pxb-internal", NULL, NULL, 0, TYPE_PXB_BUS); bus->parent_dev = dev;
Re: [Qemu-devel] [PATCH 1/8] spec: add qcow2-dirty-bitmaps specification
On 10.06.2015 18:34, Kevin Wolf wrote: Am 08.06.2015 um 17:21 hat Vladimir Sementsov-Ogievskiy geschrieben: From: Vladimir Sementsov-Ogievskiy Persistent dirty bitmaps will be saved into qcow2 files. It may be used as 'internal' bitmaps (for qcow2 drives) or as 'external' bitmaps for other drives (there may be qcow2 file with zero disk size but with several dirty bitmaps for other drives). Signed-off-by: Vladimir Sementsov-Ogievskiy --- docs/specs/qcow2.txt | 66 1 file changed, 66 insertions(+) diff --git a/docs/specs/qcow2.txt b/docs/specs/qcow2.txt index 121dfc8..0fffba2 100644 --- a/docs/specs/qcow2.txt +++ b/docs/specs/qcow2.txt @@ -123,6 +123,7 @@ be stored. Each extension has a structure like the following: 0x - End of the header extension area 0xE2792ACA - Backing file format name 0x6803f857 - Feature name table +0x23852875 - Dirty bitmaps other - Unknown header extension, can be safely ignored @@ -166,6 +167,19 @@ the header extension data. Each entry look like this: terminated if it has full length) +== Dirty bitmaps == + +Dirty bitmaps is an optional header extension. It provides a possibility of +storing dirty bitmaps in qcow2 image. The fields are: + + 0 - 3: nb_dirty_bitmaps + Number of dirty bitmaps contained in the image + + 4 - 11: dirty_bitmaps_offset + Offset into the image file at which the dirty bitmaps table + starts. Must be aligned to a cluster boundary. + + == Host cluster management == You need to use a compatibility flag because for old qemu versions, the dirty bitmaps (and associated metadata) are leaked clusters and qemu-img check would "repair" them by resetting the refcount to 0. At second sight, I see that your patches add an autoclear flag. Presumably the contents of the dirty bitmaps is outdated when you accessed the image with an older version, so this seems right. We just need to document it. qcow2 manages the allocation of host clusters by maintaining a reference count @@ -360,3 +374,55 @@ Snapshot table entry: variable: Padding to round up the snapshot table entry size to the next multiple of 8. + + +== Dirty bitmaps == + +The feature supports storing several dirty bitmaps in the qcow2 file. + +=== Cluster mapping === + +Dirty bitmaps are stored using a ONE-level structure for the mapping of +bitmaps to host clusters. There is only an L1 table. + +The L1 table has a variable size (stored in the Bitmap table entry) and may +use multiple clusters, however it must be contiguous in the image file. + +Given an offset into the bitmap, the offset into the image file can be +obtained as follows: + +offset = l1_table[offset / cluster_size] + (offset % cluster_size) + +L1 table entry: + +Bit 0 - 61: Standard cluster descriptor + +62 - 63: Reserved Stefan already mentioned that we don't have a "L1" when there is only one level, and that you shouldn't reuse the cluster descriptors from L2 tables. +=== Bitmap table === + +A directory of all bitmaps is stored in the bitmap table, a contiguous area in +the image file, whose starting offset and length are given by the header fields +dirty_bitmaps_offset and nb_dirty_bitmaps. The entries of the bitmap table have +variable length, depending on the length of name and extra data. + +Bitmap table entry: + +Byte 0 - 7:Offset into the image file at which the L1 table for the +bitmap starts. Must be aligned to a cluster boundary. + + 8 - 11:Number of entries in the L1 table of the bitmap Worth using 64 bits here? This can only cover 4 * 512 GB = 2 TB for the smallest possible cluster size. Though it's 65536 * 512 = 32 PB for the default, which might be enough for a while. +12 - 15:Bitmap granularity in bytes + +16 - 23:Bitmap size in sectors Please don't use sectors, that's a meaningless unit. Bytes is better. Just bad description. Actually it is ~ (number of bits in bitmap * granularity), and it is corresponding to number of sectors in the image. +24 - 25:Size of the bitmap name We should use a smaller limit than the possible 64k to avoid too large memory allocations. Nobody needs really long bitmap names. + +variable: The name of the bitmap (not null terminated) + +variable: Padding to round up the bitmap table entry size to the +next multiple of 8. Kevin -- Best regards, Vladimir * now, @virtuozzo.com instead of @parallels.com. Sorry for this inconvenience.
Re: [Qemu-devel] [PATCH v3 6/6] hw/pci-bridge: set explicit OFW unit address for TYPE_PXB_HOST
On 06/11/15 12:21, Marcel Apfelbaum wrote: > On 06/11/2015 03:38 AM, Laszlo Ersek wrote: >> The PXB implementation doesn't allow firmware (SeaBIOS or OVMF) to boot >> off devices behind the PXB. This happens because the >> sysbus_get_fw_dev_path() function in "hw/core/sysbus.c" doesn't have >> enough information to format a unique identifier for the PXB in question, >> and consequently the OpenFirmware device path passed down to the guest >> firmware in the "bootorder" fw_cfg file is unusable for identifying the >> boot device. >> >> For example, the command line fragment >> >>-device pxb,id=bridge1,bus_nr=4 \ >>\ >>-netdev user,id=netdev0 \ >>-device e1000,netdev=netdev0,bus=bridge1,addr=2,bootindex=0 >> >> results in the following "bootorder" entry: >> >>/pci/pci-bridge@0/ethernet@2/ethernet-phy@0 >> >> The initial "pci" node is formatted by sysbus_get_fw_dev_path(), and the >> resultant OpenFirmware device path is independent of bus_nr=4 -- and >> therefore it is useless for identifying the device. >> >> In this patch we change the fw_name device class member of TYPE_PXB_HOST >> from "pci" to "pci-root", and set each instance's explicit OFW unit >> address to the PXB bus number. The same command line fragment results in >> the following OpenFirmware device path in the "bootorder" fw_cfg file: >> >>/pci-root@4/pci-bridge@0/ethernet@2/ethernet-phy@0 > Hi Laszlo, > > I applied your patches but I still get > /pci@i0cf8/ethernet@5/ethernet-phy@0 > in the boot list > > I checked and the code enters only once in sysbus_get_fw_dev_path > for pci@i0cf8 and goes for pio branch. > > Do you know maybe what I missed? I think so, yes: you added the ...,bootorder=N property to a device that is *not* behind a PXB. :) You forgot the ...,bus=bridgeX property. Thanks Laszlo > > Thanks, > Marcel > > >> >> The original, initial "/pci" fragment has been replaced with >> "/pci-root@4", which (a) looks better, (b) provides all the necessary >> information. >> >> Cc: Markus Armbruster >> Cc: Marcel Apfelbaum >> Cc: Michael S. Tsirkin >> Signed-off-by: Laszlo Ersek >> --- >> >> Notes: >> v3: >> - using new sysbus device property, not inserting additional bus >> >> hw/pci-bridge/pci_expander_bridge.c | 7 ++- >> 1 file changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/hw/pci-bridge/pci_expander_bridge.c >> b/hw/pci-bridge/pci_expander_bridge.c >> index c7a085d..d468670 100644 >> --- a/hw/pci-bridge/pci_expander_bridge.c >> +++ b/hw/pci-bridge/pci_expander_bridge.c >> @@ -93,7 +93,7 @@ static void pxb_host_class_init(ObjectClass *class, >> void *data) >> DeviceClass *dc = DEVICE_CLASS(class); >> PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(class); >> >> -dc->fw_name = "pci"; >> +dc->fw_name = "pci-root"; >> hc->root_bus_path = pxb_host_root_bus_path; >> } >> >> @@ -152,6 +152,7 @@ static int pxb_dev_initfn(PCIDevice *dev) >> { >> PXBDev *pxb = PXB_DEV(dev); >> DeviceState *ds, *bds; >> +char *bus_nr_str; >> PCIBus *bus; >> const char *dev_name = NULL; >> >> @@ -166,6 +167,10 @@ static int pxb_dev_initfn(PCIDevice *dev) >> } >> >> ds = qdev_create(NULL, TYPE_PXB_HOST); >> +bus_nr_str = g_strdup_printf("%x", pxb->bus_nr); >> +qdev_prop_set_string(ds, "explicit_ofw_unit_address", bus_nr_str); >> +g_free(bus_nr_str); >> + >> bus = pci_bus_new(ds, "pxb-internal", NULL, NULL, 0, TYPE_PXB_BUS); >> >> bus->parent_dev = dev; >> >
Re: [Qemu-devel] virt-test broken by 'gtk: add opengl support, using egl' 97edf3bd5
* Dr. David Alan Gilbert (dgilb...@redhat.com) wrote: > Hi, > I've just bisected a virt-test breakage down to: This is fixed by the just posted 'gtk: don't exit early in case gtk init fails' Dave > > 97edf3bd5 'gtk: add opengl support, using egl' > > I think the problem is that it's trying to start X up early > on, even in the cases when qemu would just print some help and > exit. I'm running virt-test on a remote machine via ssh and > don't have DISPLAY set. > > Symptom > --- > Virt-test run of migrate.default.tcp is marked as 'SKIP' > The debug logs show: >TestNAError: usb controller ich9-usb-uhci1 not available > > Bisect: > GOOD 2.3.0 fresh iconfigure > GOOD 4d2d2d8 > GOOD a308817743be5cc051d3379477f54027deb0befb > GOOD 922cc8823e484733021a7be5b0e876eba2218623 > GOOD 9441aa282bc3213ef0530cab86f318b877bac25c > GOOD 7ced9e9f6da2257224591b91727cfeee4f3977fb > BAD 97edf3bd5eab8952d475de66ede77307c12b8c48 > BAD 63c67b6d4462b6589b371d55e3740e9f0dba3281 > BAD 2a90c454a1b90ace56ed908cd064f2fd483d1231 > BAD 39b87c7 > BAD 13644819c5bf322ae4c2a415aca77d5dbde95fe8 > BAD 6fa6b312765f698dc81b > > 97edf3bd5eab8952d475de66ede77307c12b8c48 is the first bad commit > commit 97edf3bd5eab8952d475de66ede77307c12b8c48 > Author: Gerd Hoffmann > Date: Tue Jan 20 12:43:28 2015 +0100 > > gtk: add opengl support, using egl > > > Virt-test at startup runs > > qemu -device ? > > to get a list of devices; on older versions that gives > me the list and exit's with $?=0 > > on 973ef3 it does: > [root@virtlab403 virt-test]# /root/try/bin/qemu-system-x86_64 -device '?' > > (qemu-system-x86_64:5192): Gtk-WARNING **: cannot open display: > > > (Test environment is RHEL7.1ish) > > Dave > -- > Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK > -- Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK
Re: [Qemu-devel] [PATCH v3 6/6] hw/pci-bridge: set explicit OFW unit address for TYPE_PXB_HOST
On 06/11/2015 01:26 PM, Laszlo Ersek wrote: On 06/11/15 12:21, Marcel Apfelbaum wrote: On 06/11/2015 03:38 AM, Laszlo Ersek wrote: The PXB implementation doesn't allow firmware (SeaBIOS or OVMF) to boot off devices behind the PXB. This happens because the sysbus_get_fw_dev_path() function in "hw/core/sysbus.c" doesn't have enough information to format a unique identifier for the PXB in question, and consequently the OpenFirmware device path passed down to the guest firmware in the "bootorder" fw_cfg file is unusable for identifying the boot device. For example, the command line fragment -device pxb,id=bridge1,bus_nr=4 \ \ -netdev user,id=netdev0 \ -device e1000,netdev=netdev0,bus=bridge1,addr=2,bootindex=0 results in the following "bootorder" entry: /pci/pci-bridge@0/ethernet@2/ethernet-phy@0 The initial "pci" node is formatted by sysbus_get_fw_dev_path(), and the resultant OpenFirmware device path is independent of bus_nr=4 -- and therefore it is useless for identifying the device. In this patch we change the fw_name device class member of TYPE_PXB_HOST from "pci" to "pci-root", and set each instance's explicit OFW unit address to the PXB bus number. The same command line fragment results in the following OpenFirmware device path in the "bootorder" fw_cfg file: /pci-root@4/pci-bridge@0/ethernet@2/ethernet-phy@0 Hi Laszlo, I applied your patches but I still get /pci@i0cf8/ethernet@5/ethernet-phy@0 in the boot list I checked and the code enters only once in sysbus_get_fw_dev_path for pci@i0cf8 and goes for pio branch. Do you know maybe what I missed? I think so, yes: you added the ...,bootorder=N property to a device that is *not* behind a PXB. :) You forgot the ...,bus=bridgeX property. Actually: -device pxb,id=bridge1,bus_nr=4 -netdev user,id=u \ -device e1000,id=net2,bus=bridge1,netdev=u,addr=0x5,bootindex=0,romfile=../pc-bios/efi-e1000.rom,bus=pci.0 Hmm :( Thanks Laszlo Thanks, Marcel The original, initial "/pci" fragment has been replaced with "/pci-root@4", which (a) looks better, (b) provides all the necessary information. Cc: Markus Armbruster Cc: Marcel Apfelbaum Cc: Michael S. Tsirkin Signed-off-by: Laszlo Ersek --- Notes: v3: - using new sysbus device property, not inserting additional bus hw/pci-bridge/pci_expander_bridge.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c index c7a085d..d468670 100644 --- a/hw/pci-bridge/pci_expander_bridge.c +++ b/hw/pci-bridge/pci_expander_bridge.c @@ -93,7 +93,7 @@ static void pxb_host_class_init(ObjectClass *class, void *data) DeviceClass *dc = DEVICE_CLASS(class); PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(class); -dc->fw_name = "pci"; +dc->fw_name = "pci-root"; hc->root_bus_path = pxb_host_root_bus_path; } @@ -152,6 +152,7 @@ static int pxb_dev_initfn(PCIDevice *dev) { PXBDev *pxb = PXB_DEV(dev); DeviceState *ds, *bds; +char *bus_nr_str; PCIBus *bus; const char *dev_name = NULL; @@ -166,6 +167,10 @@ static int pxb_dev_initfn(PCIDevice *dev) } ds = qdev_create(NULL, TYPE_PXB_HOST); +bus_nr_str = g_strdup_printf("%x", pxb->bus_nr); +qdev_prop_set_string(ds, "explicit_ofw_unit_address", bus_nr_str); +g_free(bus_nr_str); + bus = pci_bus_new(ds, "pxb-internal", NULL, NULL, 0, TYPE_PXB_BUS); bus->parent_dev = dev;
Re: [Qemu-devel] [PATCH 00/33] virtio 1.0 patch series rebased
On Thu, Jun 11, 2015 at 10:26:12AM +0200, Gerd Hoffmann wrote: > Hi, > > > Here's an incomplete todo for spec compliance: note that it does not > > have to block this patchset: > > - complete other devices besides net, balloon > > need to disable a bunch of features > > that 1.0 has deprecated > > So, what is the plan here? > > For legacy devices we keep the features, for backward compatibility > reasons. > > For modern devices we drop the deprecated features. > > What about transitional? Drop them too? Yes. > Implementation-wise we probably want a mask in VirtIODevice ... Exactly. > cheers, > Gerd >
Re: [Qemu-devel] [PATCH v3 2/2] vhost user: Add RARP injection for legacy guest
On Thu, Jun 11, 2015 at 01:54:22PM +0800, Jason Wang wrote: > > > On 06/11/2015 01:49 PM, Thibaut Collet wrote: > > > Yes, but still need a mechanism to notify the backend of migration > > > completion from qemu side if GUEST_ANNOUNCE is not negotiated. > > > > backend is aware of a connection with the guest (with the feature > > negociation) and can send a rarp. This rarp will be always sent by the > > backend when a VM is launched (first start or live migration > > completion) if the GUEST_ANOUNCE is not supported. > > In this case the issue is solved without done everything by QEMU. > > The issue is during migration guest network is still active. So sending > rarp too early in the destination (e.g during VM is launched) may > confuse the switch. We want it to be sent exactly when the migration is > completed in destination. It needs to be sent when backend is activated by guest kick (in case of virtio 1, it's possible to use DRIVER_OK for this). This does not happen when VM still runs on source. > > If sending a rarp message on the start of te VM is not accceptable, we > > must provide a mechanism similar of the one I have implemented. The > > message content can be empty as the backend is able to create the rarp > > message. > > Yes.
Re: [Qemu-devel] [PATCH 4/8] block: add bdrv_load_dirty_bitmap
On 11.06.2015 01:33, John Snow wrote: On 06/09/2015 12:01 PM, Stefan Hajnoczi wrote: On Mon, Jun 08, 2015 at 06:21:22PM +0300, Vladimir Sementsov-Ogievskiy wrote: +BdrvDirtyBitmap *bdrv_load_dirty_bitmap(BlockDriverState *bs, +BlockDriverState *file, +int granularity, +const char *name, +Error **errp) +{ +BlockDriver *drv = file->drv; +if (!drv) { +return NULL; +} +if (drv->bdrv_dirty_bitmap_load) { +BdrvDirtyBitmap *bitmap; +uint64_t bitmap_size = bdrv_nb_sectors(bs); +uint8_t *buf = drv->bdrv_dirty_bitmap_load(file, name, bitmap_size, + granularity); +if (buf == NULL) { +return NULL; +} + +bitmap = bdrv_create_dirty_bitmap(bs, granularity, name, errp); +if (bitmap == NULL) { +g_free(buf); +return NULL; +} + +hbitmap_deserialize_part(bitmap->bitmap, buf, 0, bitmap_size); +hbitmap_deserialize_finish(bitmap->bitmap); How about passing bitmap and errp into drv->bdrv_dirty_bitmap_load? That way bdrv_dirty_bitmap_load() can stream using hbitmap_deserialize_part() and does not need to allocate the full bitmap. It can also report errors properly. My hunch is that this was avoided because BdrvDirtyBitmap is currently a structure local only to block.c, but I would be fine with shifting the header to block_int.h and giving the BdrvDirtyBitmap some limited exposure outside of the block core file to facilitate some cleaner function prototypes here. OR, you could have the qcow2 layer rely on serialization functions that are written back here in block.c that supports feeding it out chunk-by-chunk. Whatever happens to feel cleaner is (probably) fine by me. --js I'll just use bdrv_dirty_bitmap_deserialize_part, etc, which are already in the code. -- Best regards, Vladimir * now, @virtuozzo.com instead of @parallels.com. Sorry for this inconvenience.
Re: [Qemu-devel] [PATCH v3 6/6] hw/pci-bridge: set explicit OFW unit address for TYPE_PXB_HOST
On 06/11/15 12:29, Marcel Apfelbaum wrote: > On 06/11/2015 01:26 PM, Laszlo Ersek wrote: >> On 06/11/15 12:21, Marcel Apfelbaum wrote: >>> On 06/11/2015 03:38 AM, Laszlo Ersek wrote: The PXB implementation doesn't allow firmware (SeaBIOS or OVMF) to boot off devices behind the PXB. This happens because the sysbus_get_fw_dev_path() function in "hw/core/sysbus.c" doesn't have enough information to format a unique identifier for the PXB in question, and consequently the OpenFirmware device path passed down to the guest firmware in the "bootorder" fw_cfg file is unusable for identifying the boot device. For example, the command line fragment -device pxb,id=bridge1,bus_nr=4 \ \ -netdev user,id=netdev0 \ -device e1000,netdev=netdev0,bus=bridge1,addr=2,bootindex=0 results in the following "bootorder" entry: /pci/pci-bridge@0/ethernet@2/ethernet-phy@0 The initial "pci" node is formatted by sysbus_get_fw_dev_path(), and the resultant OpenFirmware device path is independent of bus_nr=4 -- and therefore it is useless for identifying the device. In this patch we change the fw_name device class member of TYPE_PXB_HOST from "pci" to "pci-root", and set each instance's explicit OFW unit address to the PXB bus number. The same command line fragment results in the following OpenFirmware device path in the "bootorder" fw_cfg file: /pci-root@4/pci-bridge@0/ethernet@2/ethernet-phy@0 >>> Hi Laszlo, >>> >>> I applied your patches but I still get >>> /pci@i0cf8/ethernet@5/ethernet-phy@0 >>> in the boot list >>> >>> I checked and the code enters only once in sysbus_get_fw_dev_path >>> for pci@i0cf8 and goes for pio branch. >>> >>> Do you know maybe what I missed? >> >> I think so, yes: you added the ...,bootorder=N property to a device that >> is *not* behind a PXB. :) You forgot the ...,bus=bridgeX property. > > Actually: > -device pxb,id=bridge1,bus_nr=4 -netdev user,id=u \ > -device > e1000,id=net2,bus=bridge1,netdev=u,addr=0x5,bootindex=0,romfile=../pc-bios/efi-e1000.rom,bus=pci.0 > > > Hmm :( Count the "bus=" substrings on your command line :) Laszlo
Re: [Qemu-devel] [PATCH 6/8] qcow2: add autoclear bit for dirty bitmaps
On 11.06.2015 02:42, John Snow wrote: On 06/08/2015 11:21 AM, Vladimir Sementsov-Ogievskiy wrote: From: Vladimir Sementsov-Ogievskiy Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/qcow2-dirty-bitmap.c | 5 + block/qcow2.c | 13 +++-- block/qcow2.h | 9 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/block/qcow2-dirty-bitmap.c b/block/qcow2-dirty-bitmap.c index db83112..686a121 100644 --- a/block/qcow2-dirty-bitmap.c +++ b/block/qcow2-dirty-bitmap.c @@ -188,6 +188,11 @@ static int qcow2_write_dirty_bitmaps(BlockDriverState *bs) s->dirty_bitmaps_offset = dirty_bitmaps_offset; s->dirty_bitmaps_size = dirty_bitmaps_size; +if (s->nb_dirty_bitmaps > 0) { +s->autoclear_features |= QCOW2_AUTOCLEAR_DIRTY_BITMAPS; +} else { +s->autoclear_features &= ~QCOW2_AUTOCLEAR_DIRTY_BITMAPS; +} ret = qcow2_update_header(bs); if (ret < 0) { fprintf(stderr, "Could not update qcow2 header\n"); diff --git a/block/qcow2.c b/block/qcow2.c index 406e55d..f85a55a 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -182,6 +182,14 @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, return ret; } +if (!(s->autoclear_features & QCOW2_AUTOCLEAR_DIRTY_BITMAPS) && +s->nb_dirty_bitmaps > 0) { +ret = qcow2_delete_all_dirty_bitmaps(bs, errp); +if (ret < 0) { +return ret; +} +} + #ifdef DEBUG_EXT printf("Qcow2: Got dirty bitmaps extension:" " offset=%" PRIu64 " nb_bitmaps=%" PRIu32 "\n", @@ -928,8 +936,9 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, } /* Clear unknown autoclear feature bits */ -if (!bs->read_only && !(flags & BDRV_O_INCOMING) && s->autoclear_features) { -s->autoclear_features = 0; +if (!bs->read_only && !(flags & BDRV_O_INCOMING) && +(s->autoclear_features & ~QCOW2_AUTOCLEAR_MASK)) { +s->autoclear_features |= QCOW2_AUTOCLEAR_MASK; Like Stefan already mentioned, fixing this |= to &= will fix iotest 036, which is otherwise broken by this patch. ret = qcow2_update_header(bs); if (ret < 0) { error_setg_errno(errp, -ret, "Could not update qcow2 header"); diff --git a/block/qcow2.h b/block/qcow2.h index b5e576c..14bd6f9 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -215,6 +215,15 @@ enum { QCOW2_COMPAT_FEAT_MASK= QCOW2_COMPAT_LAZY_REFCOUNTS, }; +/* Autoclear feature bits */ +enum { +QCOW2_AUTOCLEAR_DIRTY_BITMAPS_BITNR = 0, +QCOW2_AUTOCLEAR_DIRTY_BITMAPS = +1 << QCOW2_AUTOCLEAR_DIRTY_BITMAPS_BITNR, + +QCOW2_AUTOCLEAR_MASK= QCOW2_AUTOCLEAR_DIRTY_BITMAPS, +}; + I find it a little awkward to have an enum with three different kinds of data in it, unless I am reading this incorrectly. (bit position, bit masks, and accumulated bit mask.) Just enumerating the indices is probably sufficient: enum { QCOW2_AUTOCLEAR_BEGIN = 0, QCOW2_AUTOCLEAR_DIRTY_BITMAPS = QCOW2_AUTOCLEAR_BEGIN, ..., QCOW2_AUTOCLEAR_END } and then the QCOW2_AUTOCLEAR_MASK can either be programmatically defined via a function, or just pre-computed as a #define. If you still want the mask definitions, you could do something cheeky like this: #define AUTOCLEAR_MASK(X) (1 << QCOW2_AUTOCLEAR_ ## X) and then you can use things like AUTOCLEAR_MASK(DIRTY_BITMAPS) without having to create and maintain two separate tables if you want both forms easily available. This enum is made like enums for QCOW2_INCOMPAT_* and QCOW2_COMPAT_*, which are already in the code... Then, may I make a patch for them too? I agree, it is strange solution to put things of different nature to one enum. enum qcow2_discard_type { QCOW2_DISCARD_NEVER = 0, QCOW2_DISCARD_ALWAYS, -- Best regards, Vladimir * now, @virtuozzo.com instead of @parallels.com. Sorry for this inconvenience.
[Qemu-devel] [PATCH] target-arm/cpu.h: remove pending_exception
This isn't used by any of the code. In fact it looks like it was never used as it came in with ARMv7 support. Signed-off-by: Alex Bennée --- target-arm/cpu.h | 1 - 1 file changed, 1 deletion(-) diff --git a/target-arm/cpu.h b/target-arm/cpu.h index 21b5b8e..7c1d95c 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -384,7 +384,6 @@ typedef struct CPUARMState { uint32_t control; int current_sp; int exception; -int pending_exception; } v7m; /* Information associated with an exception about to be taken: -- 2.4.2
Re: [Qemu-devel] [PATCH v3 6/6] hw/pci-bridge: set explicit OFW unit address for TYPE_PXB_HOST
On 06/11/2015 01:45 PM, Laszlo Ersek wrote: On 06/11/15 12:29, Marcel Apfelbaum wrote: On 06/11/2015 01:26 PM, Laszlo Ersek wrote: On 06/11/15 12:21, Marcel Apfelbaum wrote: On 06/11/2015 03:38 AM, Laszlo Ersek wrote: The PXB implementation doesn't allow firmware (SeaBIOS or OVMF) to boot off devices behind the PXB. This happens because the sysbus_get_fw_dev_path() function in "hw/core/sysbus.c" doesn't have enough information to format a unique identifier for the PXB in question, and consequently the OpenFirmware device path passed down to the guest firmware in the "bootorder" fw_cfg file is unusable for identifying the boot device. For example, the command line fragment -device pxb,id=bridge1,bus_nr=4 \ \ -netdev user,id=netdev0 \ -device e1000,netdev=netdev0,bus=bridge1,addr=2,bootindex=0 results in the following "bootorder" entry: /pci/pci-bridge@0/ethernet@2/ethernet-phy@0 The initial "pci" node is formatted by sysbus_get_fw_dev_path(), and the resultant OpenFirmware device path is independent of bus_nr=4 -- and therefore it is useless for identifying the device. In this patch we change the fw_name device class member of TYPE_PXB_HOST from "pci" to "pci-root", and set each instance's explicit OFW unit address to the PXB bus number. The same command line fragment results in the following OpenFirmware device path in the "bootorder" fw_cfg file: /pci-root@4/pci-bridge@0/ethernet@2/ethernet-phy@0 Hi Laszlo, I applied your patches but I still get /pci@i0cf8/ethernet@5/ethernet-phy@0 in the boot list I checked and the code enters only once in sysbus_get_fw_dev_path for pci@i0cf8 and goes for pio branch. Do you know maybe what I missed? I think so, yes: you added the ...,bootorder=N property to a device that is *not* behind a PXB. :) You forgot the ...,bus=bridgeX property. Actually: -device pxb,id=bridge1,bus_nr=4 -netdev user,id=u \ -device e1000,id=net2,bus=bridge1,netdev=u,addr=0x5,bootindex=0,romfile=../pc-bios/efi-e1000.rom,bus=pci.0 Hmm :( Count the "bus=" substrings on your command line :) Wow! Why would I do that to myself? I need a coffee fast! Laszlo
[Qemu-devel] [PATCH v7 2/6] spapr_pci: encode class code including Prog IF register
Current code missed the Prog IF register. All Class Code, Subclass, and Prog IF registers are needed to identify the accurate device type. For example: USB controllers use the PROG IF for denoting: USB FullSpeed, HighSpeed or SuperSpeed. Signed-off-by: Nikunj A Dadhania Reviewed-by: Thomas Huth --- hw/ppc/spapr_pci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 3ebbcd5..33254b3 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -900,8 +900,7 @@ static int spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offset, _FDT(fdt_setprop_cell(fdt, offset, "revision-id", pci_default_read_config(dev, PCI_REVISION_ID, 1))); _FDT(fdt_setprop_cell(fdt, offset, "class-code", - pci_default_read_config(dev, PCI_CLASS_DEVICE, 2) -<< 8)); + pci_default_read_config(dev, PCI_CLASS_PROG, 3))); if (pci_default_read_config(dev, PCI_INTERRUPT_PIN, 1)) { _FDT(fdt_setprop_cell(fdt, offset, "interrupts", pci_default_read_config(dev, PCI_INTERRUPT_PIN, 1))); -- 1.8.3.1
[Qemu-devel] [PATCH v7 0/6] spapr_pci: DT field fixes and PCI DT node creation in QEMU
The patch series creates PCI device tree(DT) nodes in QEMU. The new hotplug code needs the device node creation in QEMU. While during boot, nodes were created in SLOF. It makes more sense to consolidate the code to one place for better maintainability. Based on David's spapr-next https://github.com/dgibson/qemu/tree/spapr-next New slof.bin is already there in spapr-next Changelog V6: * Open coded fdt_setprop_string as the return would leak memory (Thomas Huth) Changelog V5: * Reworked enumerate bridges to reduce scopes (Alexey) * Fixed unit address which should be hex * Added FDT_NAME_MAX and use snprintf for composing name (Alexey) * Added patch to drop redundant args and change prototype (Alexey) * Added bus number in the ibm,loc-code for qemu emulated or failed vfio device. * Now qemu_:::. is having hex encoding (Alexey) Changelog V4: * Refactored and simplified the "ibm,loc-code" patch Changelog V3: * Dropped duplicate macro patches * Squashed Michael's drc_index changes to enumeration patch * Use common create routine for boottime and hotplug case * Proper error handling not depending on g_assert * Encode vfio loc-code if getting loc-code from host fails Changelog V2: * Fix device tree for 64-bit encoding * Fix the class code, was failing xhci * Remove macro duplication * Fix DT fields generation for boot time device (Michael Roth) Changelog v1: * Correct indent problems reported by checkpatch(David Gibson) * Declare sPAPRFDT structure as local (David Gibson) * Re-arrange code to avoid multiple indentation (Alexey Kardashevskiy) Nikunj A Dadhania (6): spapr_pci: encode missing 64-bit memory address space spapr_pci: encode class code including Prog IF register spapr_pci: enumerate and add PCI device tree spapr_pci: set device node unit address as hex spapr_pci: populate ibm,loc-code spapr_pci: drop redundant args in spapr_populate_pci_child_dt hw/ppc/spapr_pci.c | 261 + 1 file changed, 223 insertions(+), 38 deletions(-) -- 1.8.3.1
Re: [Qemu-devel] [PATCH] hw/vfio/platform: replace g_malloc0_n by g_malloc0
Eric Auger writes: > g_malloc0_n() is introduced since glib-2.24 while QEMU currently > requires glib-2.22. This may cause a link error on some distributions. > > Signed-off-by: Eric Auger > --- > hw/vfio/platform.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c > index 35266a8..c0acc8b 100644 > --- a/hw/vfio/platform.c > +++ b/hw/vfio/platform.c > @@ -346,8 +346,7 @@ static int vfio_populate_device(VFIODevice *vbasedev) > return ret; > } > > -vdev->regions = g_malloc0_n(vbasedev->num_regions, > -sizeof(VFIORegion *)); > +vdev->regions = g_malloc0(vbasedev->num_regions * sizeof(VFIORegion *)); > > for (i = 0; i < vbasedev->num_regions; i++) { > struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) }; Please use g_new0(VFIORegion, vbasedev->num_regions) for extra compile-time checking and integer overflow protection. See commits 58889fe net: Use g_new() & friends where that makes obvious sense 3c55fe2 scsi: Use g_new() & friends where that makes obvious sense ab3ad07 x86: Use g_new() & friends where that makes obvious sense 3ba235a block: Use g_new0() for a bit of extra type checking e1cf558 util: Use g_new() & friends where that makes obvious sense 02c4f26 block: Use g_new() & friends to avoid multiplying sizes 5839e53 block: Use g_new() & friends where that makes obvious sense
Re: [Qemu-devel] [PULL 0/1] gtk patch queue
On 11 June 2015 at 10:58, Gerd Hoffmann wrote: > Hi, > > gtk patch queue featuring a single bugfix. > > please pull, > Gerd > > The following changes since commit 0e12e61ff9a3407d123d0dbc4d945aec98d60fdf: > > Merge remote-tracking branch 'remotes/kraxel/tags/pull-vga-20150610-1' into > staging (2015-06-10 18:13:58 +0100) > > are available in the git repository at: > > > git://git.kraxel.org/qemu tags/pull-gtk-20150611-1 > > for you to fetch changes up to 060ab76356fff6a420bc881a574c40a5dda086af: > > gtk: don't exit early in case gtk init fails (2015-06-11 11:37:56 +0200) > > > gtk: don't exit early in case gtk init fails Applied, thanks. -- PMM
[Qemu-devel] [PATCH v7 6/6] spapr_pci: drop redundant args in spapr_populate_pci_child_dt
* phb_index is not being used and if required can be obtained from sphb * use helper to get drc_index in this function Suggested-by: Alexey Kardashevskiy Signed-off-by: Nikunj A Dadhania --- hw/ppc/spapr_pci.c | 12 +--- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index a7c17be..0594f38 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -937,14 +937,17 @@ static void populate_resource_props(PCIDevice *d, ResourceProps *rp) rp->assigned_len = assigned_idx * sizeof(ResourceFields); } +static uint32_t spapr_phb_get_pci_drc_index(sPAPRPHBState *phb, +PCIDevice *pdev); + static int spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offset, - int phb_index, int drc_index, sPAPRPHBState *sphb) { ResourceProps rp; bool is_bridge = false; int pci_status, err; char *buf = NULL; +uint32_t drc_index = spapr_phb_get_pci_drc_index(sphb, dev); if (pci_default_read_config(dev, PCI_HEADER_TYPE, 1) == PCI_HEADER_TYPE_BRIDGE) { @@ -1042,9 +1045,6 @@ typedef struct sPAPRFDT { sPAPRPHBState *sphb; } sPAPRFDT; -static uint32_t spapr_phb_get_pci_drc_index(sPAPRPHBState *phb, -PCIDevice *pdev); - /* create OF node for pci device and required OF DT properties */ static int spapr_create_pci_child_dt(PCIDevice *dev, sPAPRFDT *p) { @@ -1052,7 +1052,6 @@ static int spapr_create_pci_child_dt(PCIDevice *dev, sPAPRFDT *p) int slot = PCI_SLOT(dev->devfn); int func = PCI_FUNC(dev->devfn); char nodename[FDT_NAME_MAX]; -uint32_t drc_index = spapr_phb_get_pci_drc_index(p->sphb, dev); if (func != 0) { snprintf(nodename, FDT_NAME_MAX, "pci@%x,%x", slot, func); @@ -1060,8 +1059,7 @@ static int spapr_create_pci_child_dt(PCIDevice *dev, sPAPRFDT *p) snprintf(nodename, FDT_NAME_MAX, "pci@%x", slot); } offset = fdt_add_subnode(p->fdt, p->node_off, nodename); -ret = spapr_populate_pci_child_dt(dev, p->fdt, offset, p->sphb->index, - drc_index, p->sphb); +ret = spapr_populate_pci_child_dt(dev, p->fdt, offset, p->sphb); g_assert(!ret); if (ret) { return 0; -- 1.8.3.1
[Qemu-devel] [PATCH v7 5/6] spapr_pci: populate ibm,loc-code
Each hardware instance has a platform unique location code. The OF device tree that describes a part of a hardware entity must include the “ibm,loc-code” property with a value that represents the location code for that hardware entity. Populate ibm,loc-code. 1) PCI passthru devices need to identify with its own ibm,loc-code available on the host. In failure cases use: vfio_:::. 2) Emulated devices encode as following: qemu_:::. Signed-off-by: Nikunj A Dadhania --- hw/ppc/spapr_pci.c | 83 ++ 1 file changed, 72 insertions(+), 11 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index a289ae9..a7c17be 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -747,6 +747,60 @@ static AddressSpace *spapr_pci_dma_iommu(PCIBus *bus, void *opaque, int devfn) return &phb->iommu_as; } +static char *spapr_phb_vfio_get_loc_code(sPAPRPHBState *sphb, PCIDevice *pdev) +{ +char *path = NULL, *buf = NULL, *host = NULL; + +/* Get the PCI VFIO host id */ +host = object_property_get_str(OBJECT(pdev), "host", NULL); +if (!host) { +goto err_out; +} + +/* Construct the path of the file that will give us the DT location */ +path = g_strdup_printf("/sys/bus/pci/devices/%s/devspec", host); +g_free(host); +if (!path || !g_file_get_contents(path, &buf, NULL, NULL)) { +goto err_out; +} +g_free(path); + +/* Construct and read from host device tree the loc-code */ +path = g_strdup_printf("/proc/device-tree%s/ibm,loc-code", buf); +g_free(buf); +if (!path || !g_file_get_contents(path, &buf, NULL, NULL)) { +goto err_out; +} +return buf; + +err_out: +g_free(path); +return NULL; +} + +static char *spapr_phb_get_loc_code(sPAPRPHBState *sphb, PCIDevice *pdev) +{ +char *buf; +const char *devtype = "qemu"; +uint32_t busnr = pci_bus_num(PCI_BUS(qdev_get_parent_bus(DEVICE(pdev; + +if (object_dynamic_cast(OBJECT(pdev), "vfio-pci")) { +buf = spapr_phb_vfio_get_loc_code(sphb, pdev); +if (buf) { +return buf; +} +devtype = "vfio"; +} +/* + * For emulated devices and VFIO-failure case, make up + * the loc-code. + */ +buf = g_strdup_printf("%s_%s:%04x:%02x:%02x.%x", + devtype, pdev->name, sphb->index, busnr, + PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); +return buf; +} + /* Macros to operate with address in OF binding to PCI */ #define b_x(x, p, l)(((x) & ((1<<(l))-1)) << (p)) #define b_n(x) b_x((x), 31, 1) /* 0 if relocatable */ @@ -885,11 +939,12 @@ static void populate_resource_props(PCIDevice *d, ResourceProps *rp) static int spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offset, int phb_index, int drc_index, - const char *drc_name) + sPAPRPHBState *sphb) { ResourceProps rp; bool is_bridge = false; -int pci_status; +int pci_status, err; +char *buf = NULL; if (pci_default_read_config(dev, PCI_HEADER_TYPE, 1) == PCI_HEADER_TYPE_BRIDGE) { @@ -950,10 +1005,18 @@ static int spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offset, * processed by OF beforehand */ _FDT(fdt_setprop_string(fdt, offset, "name", "pci")); -if (drc_name) { -_FDT(fdt_setprop(fdt, offset, "ibm,loc-code", drc_name, - strlen(drc_name))); +buf = spapr_phb_get_loc_code(sphb, dev); +if (!buf) { +error_report("Failed setting the ibm,loc-code"); +return -1; } + +err = fdt_setprop_string(fdt, offset, "ibm,loc-code", buf); +g_free(buf); +if (err < 0) { +return err; +} + if (drc_index) { _FDT(fdt_setprop_cell(fdt, offset, "ibm,my-drc-index", drc_index)); } @@ -983,8 +1046,7 @@ static uint32_t spapr_phb_get_pci_drc_index(sPAPRPHBState *phb, PCIDevice *pdev); /* create OF node for pci device and required OF DT properties */ -static int spapr_create_pci_child_dt(PCIDevice *dev, sPAPRFDT *p, - const char *drc_name) +static int spapr_create_pci_child_dt(PCIDevice *dev, sPAPRFDT *p) { int offset, ret; int slot = PCI_SLOT(dev->devfn); @@ -999,7 +1061,7 @@ static int spapr_create_pci_child_dt(PCIDevice *dev, sPAPRFDT *p, } offset = fdt_add_subnode(p->fdt, p->node_off, nodename); ret = spapr_populate_pci_child_dt(dev, p->fdt, offset, p->sphb->index, - drc_index, drc_name); + drc_index, p->sphb); g_assert(!ret); if (ret) { return 0; @@ -1014,7 +1076,6 @@ static void spapr_phb_add_pci_device(sPAPRDRConnector *drc, { sPAPRDRConnectorClass *drc
[Qemu-devel] [PATCH v7 1/6] spapr_pci: encode missing 64-bit memory address space
The properties reg/assigned-resources need to encode 64-bit memory address space as part of phys.hi dword. 00 if configuration space 01 if IO region, 10 if 32-bit MEM region 11 if 64-bit MEM region Signed-off-by: Nikunj A Dadhania Reviewed-by: Thomas Huth --- hw/ppc/spapr_pci.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 75bab03..3ebbcd5 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -787,7 +787,13 @@ typedef struct ResourceProps { * phys.hi = 0xYYZZ, where: * 0xYY = npt000ss * ||| | - * ||| +-- space code: 1 if IO region, 2 if MEM region + * ||| +-- space code + * ||| | + * ||| + 00 if configuration space + * ||| + 01 if IO region, + * ||| + 10 if 32-bit MEM region + * ||| + 11 if 64-bit MEM region + * ||| * ||+-- for non-relocatable IO: 1 if aliased * ||for relocatable IO: 1 if below 64KB * ||for MEM: 1 if below 1MB @@ -847,6 +853,8 @@ static void populate_resource_props(PCIDevice *d, ResourceProps *rp) reg->phys_hi = cpu_to_be32(dev_id | b_(pci_bar(d, i))); if (d->io_regions[i].type & PCI_BASE_ADDRESS_SPACE_IO) { reg->phys_hi |= cpu_to_be32(b_ss(1)); +} else if (d->io_regions[i].type & PCI_BASE_ADDRESS_MEM_TYPE_64) { +reg->phys_hi |= cpu_to_be32(b_ss(3)); } else { reg->phys_hi |= cpu_to_be32(b_ss(2)); } -- 1.8.3.1
[Qemu-devel] [PATCH v7 3/6] spapr_pci: enumerate and add PCI device tree
All the PCI enumeration and device node creation was off-loaded to SLOF. With PCI hotplug support, code needed to be added to add device node. This creates multiple copy of the code one in SLOF and other in hotplug code. To unify this, the patch adds the pci device node creation in Qemu. For backward compatibility, a flag "qemu,phb-enumerated" is added to the phb, suggesting to SLOF to not do device node creation. Signed-off-by: Nikunj A Dadhania [ Squashed Michael's drc_index changes ] Signed-off-by: Michael Roth Signed-off-by: Nikunj A Dadhania --- hw/ppc/spapr_pci.c | 167 + 1 file changed, 142 insertions(+), 25 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 33254b3..6ef7f44 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -23,6 +23,7 @@ * THE SOFTWARE. */ #include "hw/hw.h" +#include "hw/sysbus.h" #include "hw/pci/pci.h" #include "hw/pci/msi.h" #include "hw/pci/msix.h" @@ -35,6 +36,7 @@ #include "qemu/error-report.h" #include "qapi/qmp/qerror.h" +#include "hw/pci/pci_bridge.h" #include "hw/pci/pci_bus.h" #include "hw/ppc/spapr_drc.h" #include "sysemu/device_tree.h" @@ -946,8 +948,13 @@ static int spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offset, * processed by OF beforehand */ _FDT(fdt_setprop_string(fdt, offset, "name", "pci")); -_FDT(fdt_setprop(fdt, offset, "ibm,loc-code", drc_name, strlen(drc_name))); -_FDT(fdt_setprop_cell(fdt, offset, "ibm,my-drc-index", drc_index)); +if (drc_name) { +_FDT(fdt_setprop(fdt, offset, "ibm,loc-code", drc_name, + strlen(drc_name))); +} +if (drc_index) { +_FDT(fdt_setprop_cell(fdt, offset, "ibm,my-drc-index", drc_index)); +} _FDT(fdt_setprop_cell(fdt, offset, "#address-cells", RESOURCE_CELLS_ADDRESS)); @@ -964,30 +971,38 @@ static int spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offset, return 0; } +typedef struct sPAPRFDT { +void *fdt; +int node_off; +sPAPRPHBState *sphb; +} sPAPRFDT; + +static uint32_t spapr_phb_get_pci_drc_index(sPAPRPHBState *phb, +PCIDevice *pdev); + /* create OF node for pci device and required OF DT properties */ -static void *spapr_create_pci_child_dt(sPAPRPHBState *phb, PCIDevice *dev, - int drc_index, const char *drc_name, - int *dt_offset) +static int spapr_create_pci_child_dt(PCIDevice *dev, sPAPRFDT *p, + const char *drc_name) { -void *fdt; -int offset, ret, fdt_size; +int offset, ret; int slot = PCI_SLOT(dev->devfn); int func = PCI_FUNC(dev->devfn); char nodename[512]; +uint32_t drc_index = spapr_phb_get_pci_drc_index(p->sphb, dev); -fdt = create_device_tree(&fdt_size); if (func != 0) { sprintf(nodename, "pci@%d,%d", slot, func); } else { sprintf(nodename, "pci@%d", slot); } -offset = fdt_add_subnode(fdt, 0, nodename); -ret = spapr_populate_pci_child_dt(dev, fdt, offset, phb->index, drc_index, - drc_name); +offset = fdt_add_subnode(p->fdt, p->node_off, nodename); +ret = spapr_populate_pci_child_dt(dev, p->fdt, offset, p->sphb->index, + drc_index, drc_name); g_assert(!ret); - -*dt_offset = offset; -return fdt; +if (ret) { +return 0; +} +return offset; } static void spapr_phb_add_pci_device(sPAPRDRConnector *drc, @@ -997,24 +1012,26 @@ static void spapr_phb_add_pci_device(sPAPRDRConnector *drc, { sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); DeviceState *dev = DEVICE(pdev); -int drc_index = drck->get_index(drc); const char *drc_name = drck->get_name(drc); -void *fdt = NULL; -int fdt_start_offset = 0; +int fdt_start_offset = 0, fdt_size; +sPAPRFDT s_fdt = {NULL, 0, NULL}; -/* boot-time devices get their device tree node created by SLOF, but for - * hotplugged devices we need QEMU to generate it so the guest can fetch - * it via RTAS - */ if (dev->hotplugged) { -fdt = spapr_create_pci_child_dt(phb, pdev, drc_index, drc_name, -&fdt_start_offset); +s_fdt.fdt = create_device_tree(&fdt_size); +s_fdt.sphb = phb; +s_fdt.node_off = 0; +fdt_start_offset = spapr_create_pci_child_dt(pdev, &s_fdt, drc_name); +if (!fdt_start_offset) { +error_setg(errp, "Failed to create pci child device tree node"); +goto out; +} } drck->attach(drc, DEVICE(pdev), - fdt, fdt_start_offset, !dev->hotplugged, errp); + s_fdt.fdt, fdt_start_offset, !dev->hotplugged, errp); +out: if (*errp) { -g_free(fdt);
Re: [Qemu-devel] [PATCH v2 RFC 0/8] block: persistent dirty bitmaps
On 10.06.2015 18:27, Stefan Hajnoczi wrote: On Mon, Jun 08, 2015 at 06:21:18PM +0300, Vladimir Sementsov-Ogievskiy wrote: QCow2 header is extended by fields 'nb_dirty_bitmaps' and 'dirty_bitmaps_offset' like with snapshots. Proposed command line syntax is the following: -dirty-bitmap [option1=val1][,option2=val2]... Two questions: 1. How does this code ensure that the dirty bitmap is consistent after crash/power failure? It's not done yet. What about consistent ('dirty' is not very good for dirty bitmaps=) flag for every bitmap? Set it on save and unset on load.. At the minimum, enabled dirty bitmaps must be discarded after crash/power failure if we cannot guarantee they are up-to-date. It's worse to rely on an outdated dirty bitmap than to detect failure and start afresh. 2. How do persistent dirty bitmaps work with live migration? Remember there are two storage cases for live migration: shared storage (NAS or SAN) and non-shared storage (disk images must be copied over). For now: Only loaded bitmaps are migrated. So, for shared image, all is ok: loaded bitmaps are migrated (in migration, if there is a bitmap with same name, size and granularity on destination, then it will be transparently used as destination bitmap), not loaded bitmaps are the same in the image. For non-shared storage, not loaded bitmaps are not migrated at all. Hmm.. is it bad? Looks like so. I can add a function to load all not loaded bitmaps from the image in disabled state. Then variants: 1) call it automatically before migration 2) add a cmd parameter, to load 'all other bitmaps' in disabled state 3) always load all available bitmaps. (1), (3) are bad I think, because bitmaps may be stored in separate file (especially for non-qcow2 images), and, if this file is not mentioned in cmd (all bitmap are not loaded), then there is no possibility of migrating them automatically. -- Best regards, Vladimir * now, @virtuozzo.com instead of @parallels.com. Sorry for this inconvenience.
[Qemu-devel] [PATCH v7 4/6] spapr_pci: set device node unit address as hex
Device node names should encode the unit address as hex, while the code was encodind it as integers. Also, use FDT_NAME_MAX macro for allocating and composing the name. Signed-off-by: Nikunj A Dadhania Reviewed-by: Thomas Huth --- hw/ppc/spapr_pci.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 6ef7f44..a289ae9 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -52,6 +52,8 @@ #define RTAS_TYPE_MSI 1 #define RTAS_TYPE_MSIX 2 +#define FDT_NAME_MAX 128 + #define _FDT(exp) \ do { \ int ret = (exp); \ @@ -987,13 +989,13 @@ static int spapr_create_pci_child_dt(PCIDevice *dev, sPAPRFDT *p, int offset, ret; int slot = PCI_SLOT(dev->devfn); int func = PCI_FUNC(dev->devfn); -char nodename[512]; +char nodename[FDT_NAME_MAX]; uint32_t drc_index = spapr_phb_get_pci_drc_index(p->sphb, dev); if (func != 0) { -sprintf(nodename, "pci@%d,%d", slot, func); +snprintf(nodename, FDT_NAME_MAX, "pci@%x,%x", slot, func); } else { -sprintf(nodename, "pci@%d", slot); +snprintf(nodename, FDT_NAME_MAX, "pci@%x", slot); } offset = fdt_add_subnode(p->fdt, p->node_off, nodename); ret = spapr_populate_pci_child_dt(dev, p->fdt, offset, p->sphb->index, @@ -1592,7 +1594,7 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb, void *fdt) { int bus_off, i, j, ret; -char nodename[256]; +char nodename[FDT_NAME_MAX]; uint32_t bus_range[] = { cpu_to_be32(0), cpu_to_be32(0xff) }; const uint64_t mmiosize = memory_region_size(&phb->memwindow); const uint64_t w32max = (1ULL << 32) - SPAPR_PCI_MEM_WIN_BUS_OFFSET; @@ -1630,7 +1632,7 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb, sPAPRFDT s_fdt; /* Start populating the FDT */ -sprintf(nodename, "pci@%" PRIx64, phb->buid); +snprintf(nodename, FDT_NAME_MAX, "pci@%" PRIx64, phb->buid); bus_off = fdt_add_subnode(fdt, 0, nodename); if (bus_off < 0) { return bus_off; -- 1.8.3.1
Re: [Qemu-devel] [PATCH v2] net:Enable vhost with vhostforce, vhost options for guests without MSI-X support
> > On 06/05/2015 10:32 PM, Pankaj Gupta wrote: > > We use vhostforce to enable vhost even if Guests don't have MSI-X > > support > > and we fall back to QEMU virtio-net. This patch will enable vhost > > unconditionally > > whenever we have vhostforce='ON' or vhost='ON'. > > > > Initially, I wanted to remove vhostforce completely as an additional > > argument. > > But after discussing this in mailing list found that some programs are > > using vhostforce > > and some vhost. So, we want to keep semantics of both the options. > > > > Signed-off-by: Pankaj Gupta > > --- > > net/tap.c | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/net/tap.c b/net/tap.c > > index d1ca314..4618359 100644 > > --- a/net/tap.c > > +++ b/net/tap.c > > @@ -649,13 +649,13 @@ static void net_init_tap_one(const NetdevTapOptions > > *tap, NetClientState *peer, > > } > > } > > > > -if (tap->has_vhost ? tap->vhost : > > -vhostfdname || (tap->has_vhostforce && tap->vhostforce)) { > > +if ((tap->has_vhost ? tap->vhost : > > +vhostfdname) || tap->vhostforce) { > > VhostNetOptions options; > > > > options.backend_type = VHOST_BACKEND_TYPE_KERNEL; > > options.net_backend = &s->nc; > > -options.force = tap->has_vhostforce && tap->vhostforce; > > +options.force = true; > > > > if (tap->has_vhostfd || tap->has_vhostfds) { > > vhostfd = monitor_fd_param(cur_mon, vhostfdname, &err); > > In this case, I believe there's no need to have vhost_net_query() and > query_guest_notifiers() callbacks (and maybe more others). I also thought on this. If same functions can be used by some other module in future? If not, I was thinking to remove those in another patch. Does the main functionality looks OK? >
[Qemu-devel] [PULL 10/42] vhost_net: add version_1 feature
Add VERSION_1 to list of features that we should test at the backend. Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- hw/net/vhost_net.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 426b23e..dc48ece 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -52,6 +52,7 @@ static const int kernel_feature_bits[] = { VIRTIO_RING_F_INDIRECT_DESC, VIRTIO_RING_F_EVENT_IDX, VIRTIO_NET_F_MRG_RXBUF, +VIRTIO_F_VERSION_1, VHOST_INVALID_FEATURE_BIT }; @@ -62,6 +63,7 @@ static const int user_feature_bits[] = { VIRTIO_RING_F_EVENT_IDX, VIRTIO_F_ANY_LAYOUT, +VIRTIO_F_VERSION_1, VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GUEST_CSUM, VIRTIO_NET_F_GSO, -- MST
[Qemu-devel] [PULL 05/42] virtio: disallow late feature changes for virtio-1
From: Cornelia Huck For virtio-1 devices, the driver must not attempt to set feature bits after it set FEATURES_OK in the device status. Simply reject it in that case. Signed-off-by: Cornelia Huck Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 18 +++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index c27e975..3367100 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1021,7 +1021,7 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f) vmstate_save_state(f, &vmstate_virtio, vdev, NULL); } -int virtio_set_features(VirtIODevice *vdev, uint64_t val) +static int virtio_set_features_nocheck(VirtIODevice *vdev, uint64_t val) { VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev); bool bad = (val & ~(vdev->host_features)) != 0; @@ -1034,6 +1034,18 @@ int virtio_set_features(VirtIODevice *vdev, uint64_t val) return bad ? -1 : 0; } +int virtio_set_features(VirtIODevice *vdev, uint64_t val) +{ + /* + * The driver must not attempt to set features after feature negotiation + * has finished. + */ +if (vdev->status & VIRTIO_CONFIG_S_FEATURES_OK) { +return -EINVAL; +} +return virtio_set_features_nocheck(vdev, val); +} + int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id) { int i, ret; @@ -1137,14 +1149,14 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id) * host_features. */ uint64_t features64 = vdev->guest_features; -if (virtio_set_features(vdev, features64) < 0) { +if (virtio_set_features_nocheck(vdev, features64) < 0) { error_report("Features 0x%" PRIx64 " unsupported. " "Allowed features: 0x%" PRIx64, features64, vdev->host_features); return -1; } } else { -if (virtio_set_features(vdev, features) < 0) { +if (virtio_set_features_nocheck(vdev, features) < 0) { error_report("Features 0x%x unsupported. " "Allowed features: 0x%" PRIx64, features, vdev->host_features); -- MST
[Qemu-devel] [PULL 12/42] linux-headers: add virtio_pci
Easier than duplicating code. Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- linux-headers/linux/virtio_pci.h | 192 +++ hw/virtio/virtio-pci.c | 2 + 2 files changed, 194 insertions(+) create mode 100644 linux-headers/linux/virtio_pci.h diff --git a/linux-headers/linux/virtio_pci.h b/linux-headers/linux/virtio_pci.h new file mode 100644 index 000..92624e5 --- /dev/null +++ b/linux-headers/linux/virtio_pci.h @@ -0,0 +1,192 @@ +/* + * Virtio PCI driver + * + * This module allows virtio devices to be used over a virtual PCI device. + * This can be used with QEMU based VMMs like KVM or Xen. + * + * Copyright IBM Corp. 2007 + * + * Authors: + * Anthony Liguori + * + * This header is BSD licensed so anyone can use the definitions to implement + * compatible drivers/servers. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * 3. Neither the name of IBM nor the names of its contributors + *may be used to endorse or promote products derived from this software + *without specific prior written permission. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _LINUX_VIRTIO_PCI_H +#define _LINUX_VIRTIO_PCI_H + +#include + +#ifndef VIRTIO_PCI_NO_LEGACY + +/* A 32-bit r/o bitmask of the features supported by the host */ +#define VIRTIO_PCI_HOST_FEATURES 0 + +/* A 32-bit r/w bitmask of features activated by the guest */ +#define VIRTIO_PCI_GUEST_FEATURES 4 + +/* A 32-bit r/w PFN for the currently selected queue */ +#define VIRTIO_PCI_QUEUE_PFN 8 + +/* A 16-bit r/o queue size for the currently selected queue */ +#define VIRTIO_PCI_QUEUE_NUM 12 + +/* A 16-bit r/w queue selector */ +#define VIRTIO_PCI_QUEUE_SEL 14 + +/* A 16-bit r/w queue notifier */ +#define VIRTIO_PCI_QUEUE_NOTIFY16 + +/* An 8-bit device status register. */ +#define VIRTIO_PCI_STATUS 18 + +/* An 8-bit r/o interrupt status register. Reading the value will return the + * current contents of the ISR and will also clear it. This is effectively + * a read-and-acknowledge. */ +#define VIRTIO_PCI_ISR 19 + +/* MSI-X registers: only enabled if MSI-X is enabled. */ +/* A 16-bit vector for configuration changes. */ +#define VIRTIO_MSI_CONFIG_VECTOR20 +/* A 16-bit vector for selected queue notifications. */ +#define VIRTIO_MSI_QUEUE_VECTOR 22 + +/* The remaining space is defined by each driver as the per-driver + * configuration space */ +#define VIRTIO_PCI_CONFIG_OFF(msix_enabled)((msix_enabled) ? 24 : 20) +/* Deprecated: please use VIRTIO_PCI_CONFIG_OFF instead */ +#define VIRTIO_PCI_CONFIG(dev) VIRTIO_PCI_CONFIG_OFF((dev)->msix_enabled) + +/* Virtio ABI version, this must match exactly */ +#define VIRTIO_PCI_ABI_VERSION 0 + +/* How many bits to shift physical queue address written to QUEUE_PFN. + * 12 is historical, and due to x86 page size. */ +#define VIRTIO_PCI_QUEUE_ADDR_SHIFT12 + +/* The alignment to use between consumer and producer parts of vring. + * x86 pagesize again. */ +#define VIRTIO_PCI_VRING_ALIGN 4096 + +#endif /* VIRTIO_PCI_NO_LEGACY */ + +/* The bit of the ISR which indicates a device configuration change. */ +#define VIRTIO_PCI_ISR_CONFIG 0x2 +/* Vector value used to disable MSI for queue */ +#define VIRTIO_MSI_NO_VECTOR0x + +#ifndef VIRTIO_PCI_NO_MODERN + +/* IDs for different capabilities. Must all exist. */ + +/* Common configuration */ +#define VIRTIO_PCI_CAP_COMMON_CFG 1 +/* Notifications */ +#define VIRTIO_PCI_CAP_NOTIFY_CFG 2 +/* ISR access */ +#define VIRTIO_PCI_CAP_ISR_CFG 3 +/* Device specific confiuration */ +#define VIRTIO_PCI_CAP_DEVICE_CFG 4 + +/* This is the PCI ca
[Qemu-devel] [PULL 08/42] virtio-net: support longer header
From: Cornelia Huck virtio-1 devices always use num_buffers in the header, even if mergeable rx buffers have not been negotiated. Signed-off-by: Cornelia Huck Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- hw/net/virtio-net.c | 21 +++-- 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index e2d2ab5..a01c4d1 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -367,15 +367,21 @@ static int peer_has_ufo(VirtIONet *n) return n->has_ufo; } -static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, int mergeable_rx_bufs) +static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, int mergeable_rx_bufs, + int version_1) { int i; NetClientState *nc; n->mergeable_rx_bufs = mergeable_rx_bufs; -n->guest_hdr_len = n->mergeable_rx_bufs ? -sizeof(struct virtio_net_hdr_mrg_rxbuf) : sizeof(struct virtio_net_hdr); +if (version_1) { +n->guest_hdr_len = sizeof(struct virtio_net_hdr_mrg_rxbuf); +} else { +n->guest_hdr_len = n->mergeable_rx_bufs ? +sizeof(struct virtio_net_hdr_mrg_rxbuf) : +sizeof(struct virtio_net_hdr); +} for (i = 0; i < n->max_queues; i++) { nc = qemu_get_subqueue(n->nic, i); @@ -522,7 +528,9 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features) virtio_net_set_mrg_rx_bufs(n, __virtio_has_feature(features, -VIRTIO_NET_F_MRG_RXBUF)); +VIRTIO_NET_F_MRG_RXBUF), + __virtio_has_feature(features, +VIRTIO_F_VERSION_1)); if (n->has_vnet_hdr) { n->curr_guest_offloads = @@ -1375,7 +1383,8 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f, qemu_get_buffer(f, n->mac, ETH_ALEN); n->vqs[0].tx_waiting = qemu_get_be32(f); -virtio_net_set_mrg_rx_bufs(n, qemu_get_be32(f)); +virtio_net_set_mrg_rx_bufs(n, qemu_get_be32(f), + virtio_has_feature(vdev, VIRTIO_F_VERSION_1)); if (version_id >= 3) n->status = qemu_get_be16(f); @@ -1627,7 +1636,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) n->vqs[0].tx_waiting = 0; n->tx_burst = n->net_conf.txburst; -virtio_net_set_mrg_rx_bufs(n, 0); +virtio_net_set_mrg_rx_bufs(n, 0, 0); n->promisc = 1; /* for compatibility */ n->mac_table.macs = g_malloc0(MAC_TABLE_ENTRIES * ETH_ALEN); -- MST
[Qemu-devel] [PULL 09/42] virtio-net: enable virtio 1.0
From: Cornelia Huck virtio-net (non-vhost) now should have everything in place to support virtio 1.0: let's enable the feature bit for it. Note that VIRTIO_F_VERSION_1 is technically a transport feature; once every device is ready for virtio 1.0, we can move setting this feature bit out of the individual devices. Signed-off-by: Cornelia Huck Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- hw/net/virtio-net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index a01c4d1..49fa13f 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -470,6 +470,7 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features) } if (!get_vhost_net(nc->peer)) { +virtio_add_feature(&features, VIRTIO_F_VERSION_1); return features; } return vhost_net_get_features(get_vhost_net(nc->peer), features); -- MST
[Qemu-devel] [PULL 04/42] dataplane: allow virtio-1 devices
From: Cornelia Huck Handle endianness conversion for virtio-1 virtqueues correctly. Note that dataplane now needs to be built per-target. Signed-off-by: Cornelia Huck Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- hw/virtio/dataplane/vring.c | 47 + 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/hw/virtio/dataplane/vring.c b/hw/virtio/dataplane/vring.c index 5c7b8c2..fabb810 100644 --- a/hw/virtio/dataplane/vring.c +++ b/hw/virtio/dataplane/vring.c @@ -157,15 +157,18 @@ bool vring_should_notify(VirtIODevice *vdev, Vring *vring) } -static int get_desc(Vring *vring, VirtQueueElement *elem, +static int get_desc(VirtIODevice *vdev, Vring *vring, VirtQueueElement *elem, struct vring_desc *desc) { unsigned *num; struct iovec *iov; hwaddr *addr; MemoryRegion *mr; +int is_write = virtio_tswap16(vdev, desc->flags) & VRING_DESC_F_WRITE; +uint32_t len = virtio_tswap32(vdev, desc->len); +uint64_t desc_addr = virtio_tswap64(vdev, desc->addr); -if (desc->flags & VRING_DESC_F_WRITE) { +if (is_write) { num = &elem->in_num; iov = &elem->in_sg[*num]; addr = &elem->in_addr[*num]; @@ -189,18 +192,17 @@ static int get_desc(Vring *vring, VirtQueueElement *elem, } /* TODO handle non-contiguous memory across region boundaries */ -iov->iov_base = vring_map(&mr, desc->addr, desc->len, - desc->flags & VRING_DESC_F_WRITE); +iov->iov_base = vring_map(&mr, desc_addr, len, is_write); if (!iov->iov_base) { error_report("Failed to map descriptor addr %#" PRIx64 " len %u", - (uint64_t)desc->addr, desc->len); + (uint64_t)desc_addr, len); return -EFAULT; } /* The MemoryRegion is looked up again and unref'ed later, leave the * ref in place. */ -iov->iov_len = desc->len; -*addr = desc->addr; +iov->iov_len = len; +*addr = desc_addr; *num += 1; return 0; } @@ -222,21 +224,23 @@ static int get_indirect(VirtIODevice *vdev, Vring *vring, struct vring_desc desc; unsigned int i = 0, count, found = 0; int ret; +uint32_t len = virtio_tswap32(vdev, indirect->len); +uint64_t addr = virtio_tswap64(vdev, indirect->addr); /* Sanity check */ -if (unlikely(indirect->len % sizeof(desc))) { +if (unlikely(len % sizeof(desc))) { error_report("Invalid length in indirect descriptor: " "len %#x not multiple of %#zx", - indirect->len, sizeof(desc)); + len, sizeof(desc)); vring->broken = true; return -EFAULT; } -count = indirect->len / sizeof(desc); +count = len / sizeof(desc); /* Buffers are chained via a 16 bit next field, so * we can have at most 2^16 of these. */ if (unlikely(count > USHRT_MAX + 1)) { -error_report("Indirect buffer length too big: %d", indirect->len); +error_report("Indirect buffer length too big: %d", len); vring->broken = true; return -EFAULT; } @@ -247,12 +251,12 @@ static int get_indirect(VirtIODevice *vdev, Vring *vring, /* Translate indirect descriptor */ desc_ptr = vring_map(&mr, - indirect->addr + found * sizeof(desc), + addr + found * sizeof(desc), sizeof(desc), false); if (!desc_ptr) { error_report("Failed to map indirect descriptor " "addr %#" PRIx64 " len %zu", - (uint64_t)indirect->addr + found * sizeof(desc), + (uint64_t)addr + found * sizeof(desc), sizeof(desc)); vring->broken = true; return -EFAULT; @@ -270,19 +274,20 @@ static int get_indirect(VirtIODevice *vdev, Vring *vring, return -EFAULT; } -if (unlikely(desc.flags & VRING_DESC_F_INDIRECT)) { +if (unlikely(virtio_tswap16(vdev, desc.flags) + & VRING_DESC_F_INDIRECT)) { error_report("Nested indirect descriptor"); vring->broken = true; return -EFAULT; } -ret = get_desc(vring, elem, &desc); +ret = get_desc(vdev, vring, elem, &desc); if (ret < 0) { vring->broken |= (ret == -EFAULT); return ret; } -i = desc.next; -} while (desc.flags & VRING_DESC_F_NEXT); +i = virtio_tswap16(vdev, desc.next); +} while (virtio_tswap16(vdev, desc.flags) & VRING_DESC_F_NEXT); return 0; } @@ -383,7 +388,7 @@ int vring_pop(VirtIODevice *vdev, Vring *vring, /* Ensure descriptor is loaded before accessing fields */ barrier(); -if (desc.flags & VRING_DESC_F_INDIRECT)
[Qemu-devel] [PULL 14/42] virtio: generation counter support
Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 1 + hw/virtio/virtio-pci.c | 2 +- hw/virtio/virtio.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index df89913..b9e36f9 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -78,6 +78,7 @@ struct VirtIODevice size_t config_len; void *config; uint16_t config_vector; +uint32_t generation; int nvectors; VirtQueue *vq; uint16_t device_id; diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 8fc3c4e..7805bdd 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -977,7 +977,7 @@ static uint64_t virtio_pci_common_read(void *opaque, hwaddr addr, val = vdev->status; break; case VIRTIO_PCI_COMMON_CFGGENERATION: -val = 0; /* TODO */ +val = vdev->generation; break; case VIRTIO_PCI_COMMON_Q_SELECT: val = vdev->queue_sel; diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 8a6ebae..cae5eca 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -930,6 +930,7 @@ void virtio_notify_config(VirtIODevice *vdev) return; vdev->isr |= 0x03; +vdev->generation++; virtio_notify_vector(vdev, vdev->config_vector); } -- MST
[Qemu-devel] [PULL 15/42] virtio: add modern config accessors
virtio 1.0 defines config space as LE, as opposed to pre-1.0 which was native endian. Add API for transports to execute word/dword accesses in little endian format - will be useful for mmio and pci (byte access is also wrapped, for completeness). For simplicity, we still keep config in host native endian format, byteswap to LE on guest access. Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 9 + hw/virtio/virtio.c | 96 ++ 2 files changed, 105 insertions(+) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index b9e36f9..473fb75 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -174,6 +174,15 @@ uint32_t virtio_config_readl(VirtIODevice *vdev, uint32_t addr); void virtio_config_writeb(VirtIODevice *vdev, uint32_t addr, uint32_t data); void virtio_config_writew(VirtIODevice *vdev, uint32_t addr, uint32_t data); void virtio_config_writel(VirtIODevice *vdev, uint32_t addr, uint32_t data); +uint32_t virtio_config_modern_readb(VirtIODevice *vdev, uint32_t addr); +uint32_t virtio_config_modern_readw(VirtIODevice *vdev, uint32_t addr); +uint32_t virtio_config_modern_readl(VirtIODevice *vdev, uint32_t addr); +void virtio_config_modern_writeb(VirtIODevice *vdev, + uint32_t addr, uint32_t data); +void virtio_config_modern_writew(VirtIODevice *vdev, + uint32_t addr, uint32_t data); +void virtio_config_modern_writel(VirtIODevice *vdev, + uint32_t addr, uint32_t data); void virtio_queue_set_addr(VirtIODevice *vdev, int n, hwaddr addr); hwaddr virtio_queue_get_addr(VirtIODevice *vdev, int n); void virtio_queue_set_num(VirtIODevice *vdev, int n, int num); diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index cae5eca..fb49ffc 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -729,6 +729,102 @@ void virtio_config_writel(VirtIODevice *vdev, uint32_t addr, uint32_t data) } } +uint32_t virtio_config_modern_readb(VirtIODevice *vdev, uint32_t addr) +{ +VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev); +uint8_t val; + +if (addr + sizeof(val) > vdev->config_len) { +return (uint32_t)-1; +} + +k->get_config(vdev, vdev->config); + +val = ldub_p(vdev->config + addr); +return val; +} + +uint32_t virtio_config_modern_readw(VirtIODevice *vdev, uint32_t addr) +{ +VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev); +uint16_t val; + +if (addr + sizeof(val) > vdev->config_len) { +return (uint32_t)-1; +} + +k->get_config(vdev, vdev->config); + +val = lduw_le_p(vdev->config + addr); +return val; +} + +uint32_t virtio_config_modern_readl(VirtIODevice *vdev, uint32_t addr) +{ +VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev); +uint32_t val; + +if (addr + sizeof(val) > vdev->config_len) { +return (uint32_t)-1; +} + +k->get_config(vdev, vdev->config); + +val = ldl_le_p(vdev->config + addr); +return val; +} + +void virtio_config_modern_writeb(VirtIODevice *vdev, + uint32_t addr, uint32_t data) +{ +VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev); +uint8_t val = data; + +if (addr + sizeof(val) > vdev->config_len) { +return; +} + +stb_p(vdev->config + addr, val); + +if (k->set_config) { +k->set_config(vdev, vdev->config); +} +} + +void virtio_config_modern_writew(VirtIODevice *vdev, + uint32_t addr, uint32_t data) +{ +VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev); +uint16_t val = data; + +if (addr + sizeof(val) > vdev->config_len) { +return; +} + +stw_le_p(vdev->config + addr, val); + +if (k->set_config) { +k->set_config(vdev, vdev->config); +} +} + +void virtio_config_modern_writel(VirtIODevice *vdev, + uint32_t addr, uint32_t data) +{ +VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev); +uint32_t val = data; + +if (addr + sizeof(val) > vdev->config_len) { +return; +} + +stl_le_p(vdev->config + addr, val); + +if (k->set_config) { +k->set_config(vdev, vdev->config); +} +} + void virtio_queue_set_addr(VirtIODevice *vdev, int n, hwaddr addr) { vdev->vq[n].vring.desc = addr; -- MST
[Qemu-devel] [PULL 02/42] virtio: endianness checks for virtio 1.0 devices
From: Cornelia Huck Add code that checks for the VERSION_1 feature bit in order to make decisions about the device's endianness. This allows us to support transitional devices. Signed-off-by: Cornelia Huck Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- include/hw/virtio/virtio-access.h | 4 include/hw/virtio/virtio.h| 8 ++-- hw/virtio/virtio.c| 6 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-access.h index 46456fd..ee28c21 100644 --- a/include/hw/virtio/virtio-access.h +++ b/include/hw/virtio/virtio-access.h @@ -19,6 +19,10 @@ static inline bool virtio_access_is_big_endian(VirtIODevice *vdev) { +if (virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { +/* Devices conforming to VIRTIO 1.0 or later are always LE. */ +return false; +} #if defined(TARGET_IS_BIENDIAN) return virtio_is_big_endian(vdev); #elif defined(TARGET_WORDS_BIGENDIAN) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 2bb7c1a..13e8549 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -252,7 +252,11 @@ static inline bool virtio_has_feature(VirtIODevice *vdev, unsigned int fbit) static inline bool virtio_is_big_endian(VirtIODevice *vdev) { -assert(vdev->device_endian != VIRTIO_DEVICE_ENDIAN_UNKNOWN); -return vdev->device_endian == VIRTIO_DEVICE_ENDIAN_BIG; +if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { +assert(vdev->device_endian != VIRTIO_DEVICE_ENDIAN_UNKNOWN); +return vdev->device_endian == VIRTIO_DEVICE_ENDIAN_BIG; +} +/* Devices conforming to VIRTIO 1.0 or later are always LE. */ +return false; } #endif diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 8ac6156..d37d27b 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -903,7 +903,11 @@ static bool virtio_device_endian_needed(void *opaque) VirtIODevice *vdev = opaque; assert(vdev->device_endian != VIRTIO_DEVICE_ENDIAN_UNKNOWN); -return vdev->device_endian != virtio_default_endian(); +if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { +return vdev->device_endian != virtio_default_endian(); +} +/* Devices conforming to VIRTIO 1.0 or later are always LE. */ +return vdev->device_endian != VIRTIO_DEVICE_ENDIAN_LITTLE; } static bool virtio_64bit_features_needed(void *opaque) -- MST
[Qemu-devel] [PULL 13/42] virtio-pci: initial virtio 1.0 support
This is somewhat functional. With this, and linux driver from my tree, I was able to use virtio net as virtio 1.0 device for light browsing. At the moment, dataplane and vhost code is still missing. Based on Cornelia's virtio 1.0 patchset: Date: Thu, 11 Dec 2014 14:25:02 +0100 From: Cornelia Huck To: virtualizat...@lists.linux-foundation.org, qemu-devel@nongnu.org Cc: ru...@rustcorp.com.au, th...@linux.vnet.ibm.com, m...@redhat.com, Cornelia Huck Subject: [PATCH RFC v6 00/20] qemu: towards virtio-1 host support Message-Id: <1418304322-7546-1-git-send-email-cornelia.h...@de.ibm.com> which is itself still missing some core bits. Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.h | 16 +++ hw/virtio/virtio-pci.c | 379 + 2 files changed, 395 insertions(+) diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h index de39468..7a6481f 100644 --- a/hw/virtio/virtio-pci.h +++ b/hw/virtio/virtio-pci.h @@ -88,9 +88,25 @@ typedef struct VirtioPCIClass { struct VirtIOPCIProxy { PCIDevice pci_dev; MemoryRegion bar; +MemoryRegion common; +MemoryRegion isr; +MemoryRegion device; +MemoryRegion notify; +MemoryRegion modern_bar; uint32_t flags; uint32_t class_code; uint32_t nvectors; +uint32_t dfselect; +uint32_t gfselect; +uint32_t guest_features[2]; +struct { +uint16_t num; +bool enabled; +uint32_t desc[2]; +uint32_t avail[2]; +uint32_t used[2]; +} vqs[VIRTIO_QUEUE_MAX]; + bool ioeventfd_disabled; bool ioeventfd_started; VirtIOIRQFD *vector_irqfd; diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 8dca87c..8fc3c4e 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -920,6 +920,278 @@ static int virtio_pci_query_nvectors(DeviceState *d) return proxy->nvectors; } +static void virtio_pci_add_mem_cap(VirtIOPCIProxy *proxy, + struct virtio_pci_cap *cap) +{ +PCIDevice *dev = &proxy->pci_dev; +int offset; + +cap->bar = 2; + +offset = pci_add_capability(dev, PCI_CAP_ID_VNDR, 0, cap->cap_len); +assert(offset > 0); + +assert(cap->cap_len >= sizeof *cap); +memcpy(dev->config + offset + PCI_CAP_FLAGS, &cap->cap_len, + cap->cap_len - PCI_CAP_FLAGS); +} + +#define QEMU_VIRTIO_PCI_QUEUE_MEM_MULT 0x1 + +static uint64_t virtio_pci_common_read(void *opaque, hwaddr addr, + unsigned size) +{ +VirtIOPCIProxy *proxy = opaque; +VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); +uint32_t val = 0; +int i; + +switch (addr) { +case VIRTIO_PCI_COMMON_DFSELECT: +val = proxy->dfselect; +break; +case VIRTIO_PCI_COMMON_DF: +if (proxy->dfselect <= 1) { +val = vdev->host_features >> (32 * proxy->dfselect); +} +break; +case VIRTIO_PCI_COMMON_GFSELECT: +val = proxy->gfselect; +break; +case VIRTIO_PCI_COMMON_GF: +if (proxy->gfselect <= ARRAY_SIZE(proxy->guest_features)) { +val = proxy->guest_features[proxy->gfselect]; +} +break; +case VIRTIO_PCI_COMMON_MSIX: +val = vdev->config_vector; +break; +case VIRTIO_PCI_COMMON_NUMQ: +for (i = 0; i < VIRTIO_QUEUE_MAX; ++i) { +if (virtio_queue_get_num(vdev, i)) { +val = i + 1; +} +} +break; +case VIRTIO_PCI_COMMON_STATUS: +val = vdev->status; +break; +case VIRTIO_PCI_COMMON_CFGGENERATION: +val = 0; /* TODO */ +break; +case VIRTIO_PCI_COMMON_Q_SELECT: +val = vdev->queue_sel; +break; +case VIRTIO_PCI_COMMON_Q_SIZE: +val = virtio_queue_get_num(vdev, vdev->queue_sel); +break; +case VIRTIO_PCI_COMMON_Q_MSIX: +val = virtio_queue_vector(vdev, vdev->queue_sel); +break; +case VIRTIO_PCI_COMMON_Q_ENABLE: +val = proxy->vqs[vdev->queue_sel].enabled; +break; +case VIRTIO_PCI_COMMON_Q_NOFF: +/* Simply map queues in order */ +val = vdev->queue_sel; +break; +case VIRTIO_PCI_COMMON_Q_DESCLO: +val = proxy->vqs[vdev->queue_sel].desc[0]; +break; +case VIRTIO_PCI_COMMON_Q_DESCHI: +val = proxy->vqs[vdev->queue_sel].desc[1]; +break; +case VIRTIO_PCI_COMMON_Q_AVAILLO: +val = proxy->vqs[vdev->queue_sel].avail[0]; +break; +case VIRTIO_PCI_COMMON_Q_AVAILHI: +val = proxy->vqs[vdev->queue_sel].avail[1]; +break; +case VIRTIO_PCI_COMMON_Q_USEDLO: +val = proxy->vqs[vdev->queue_sel].used[0]; +break; +case VIRTIO_PCI_COMMON_Q_USEDHI: +val = proxy->vqs[vdev->queue_sel].used[1]; +break; +default: +val = 0; +} + +return val; +} + +static vo
[Qemu-devel] [PULL 06/42] virtio: allow to fail setting status
From: Cornelia Huck virtio-1 allow setting of the FEATURES_OK status bit to fail if the negotiated feature bits are inconsistent: let's fail virtio_set_status() in that case and update virtio-ccw to post an error to the guest. Signed-off-by: Cornelia Huck Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 3 ++- hw/s390x/virtio-ccw.c | 20 hw/virtio/virtio.c | 24 +++- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index b877a93..df89913 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -99,6 +99,7 @@ typedef struct VirtioDeviceClass { uint64_t (*get_features)(VirtIODevice *vdev, uint64_t requested_features); uint64_t (*bad_features)(VirtIODevice *vdev); void (*set_features)(VirtIODevice *vdev, uint64_t val); +int (*validate_features)(VirtIODevice *vdev); void (*get_config)(VirtIODevice *vdev, uint8_t *config); void (*set_config)(VirtIODevice *vdev, const uint8_t *config); void (*reset)(VirtIODevice *vdev); @@ -184,7 +185,7 @@ void virtio_queue_set_align(VirtIODevice *vdev, int n, int align); void virtio_queue_notify(VirtIODevice *vdev, int n); uint16_t virtio_queue_vector(VirtIODevice *vdev, int n); void virtio_queue_set_vector(VirtIODevice *vdev, int n, uint16_t vector); -void virtio_set_status(VirtIODevice *vdev, uint8_t val); +int virtio_set_status(VirtIODevice *vdev, uint8_t val); void virtio_reset(void *opaque); void virtio_update_irq(VirtIODevice *vdev); int virtio_set_features(VirtIODevice *vdev, uint64_t val); diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index ef90fed..3ef0055 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -497,15 +497,19 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) if (!(status & VIRTIO_CONFIG_S_DRIVER_OK)) { virtio_ccw_stop_ioeventfd(dev); } -virtio_set_status(vdev, status); -if (vdev->status == 0) { -virtio_reset(vdev); -} -if (status & VIRTIO_CONFIG_S_DRIVER_OK) { -virtio_ccw_start_ioeventfd(dev); +if (virtio_set_status(vdev, status) == 0) { +if (vdev->status == 0) { +virtio_reset(vdev); +} +if (status & VIRTIO_CONFIG_S_DRIVER_OK) { +virtio_ccw_start_ioeventfd(dev); +} +sch->curr_status.scsw.count = ccw.count - sizeof(status); +ret = 0; +} else { +/* Trigger a command reject. */ +ret = -ENOSYS; } -sch->curr_status.scsw.count = ccw.count - sizeof(status); -ret = 0; } break; case CCW_CMD_SET_IND: diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 3367100..8a6ebae 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -544,15 +544,37 @@ void virtio_update_irq(VirtIODevice *vdev) virtio_notify_vector(vdev, VIRTIO_NO_VECTOR); } -void virtio_set_status(VirtIODevice *vdev, uint8_t val) +static int virtio_validate_features(VirtIODevice *vdev) +{ +VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev); + +if (k->validate_features) { +return k->validate_features(vdev); +} else { +return 0; +} +} + +int virtio_set_status(VirtIODevice *vdev, uint8_t val) { VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev); trace_virtio_set_status(vdev, val); +if (virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { +if (!(vdev->status & VIRTIO_CONFIG_S_FEATURES_OK) && +val & VIRTIO_CONFIG_S_FEATURES_OK) { +int ret = virtio_validate_features(vdev); + +if (ret) { +return ret; +} +} +} if (k->set_status) { k->set_status(vdev, val); } vdev->status = val; +return 0; } bool target_words_bigendian(void); -- MST
[Qemu-devel] [PULL 27/42] virtio-pci: move virtio_pci_add_mem_cap call to virtio_pci_modern_region_map
From: Gerd Hoffmann Also fill offset and length automatically, from VirtIOPCIRegion->offset and region size. Signed-off-by: Gerd Hoffmann Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.c | 28 ++-- 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 759cfc4..f4bdd1c 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1275,11 +1275,16 @@ static void virtio_pci_modern_regions_init(VirtIOPCIProxy *proxy) } static void virtio_pci_modern_region_map(VirtIOPCIProxy *proxy, - VirtIOPCIRegion *region) + VirtIOPCIRegion *region, + struct virtio_pci_cap *cap) { memory_region_add_subregion(&proxy->modern_bar, region->offset, ®ion->mr); + +cap->offset = cpu_to_le32(region->offset); +cap->length = cpu_to_le32(memory_region_size(®ion->mr)); +virtio_pci_add_mem_cap(proxy, cap); } /* This is called by virtio-bus just after the device is plugged. */ @@ -1335,49 +1340,36 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) .cfg_type = VIRTIO_PCI_CAP_COMMON_CFG, .cap_len = sizeof common, .bar = modern_mem_bar, -.offset = cpu_to_le32(0x0), -.length = cpu_to_le32(0x1000), }; struct virtio_pci_cap isr = { .cfg_type = VIRTIO_PCI_CAP_ISR_CFG, .cap_len = sizeof isr, .bar = modern_mem_bar, -.offset = cpu_to_le32(0x1000), -.length = cpu_to_le32(0x1000), }; struct virtio_pci_cap device = { .cfg_type = VIRTIO_PCI_CAP_DEVICE_CFG, .cap_len = sizeof device, .bar = modern_mem_bar, -.offset = cpu_to_le32(0x2000), -.length = cpu_to_le32(0x1000), }; struct virtio_pci_notify_cap notify = { .cap.cfg_type = VIRTIO_PCI_CAP_NOTIFY_CFG, .cap.cap_len = sizeof notify, .cap.bar = modern_mem_bar, -.cap.offset = cpu_to_le32(0x3000), -.cap.length = cpu_to_le32(QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * - VIRTIO_QUEUE_MAX), .notify_off_multiplier = cpu_to_le32(QEMU_VIRTIO_PCI_QUEUE_MEM_MULT), }; /* TODO: add io access for speed */ -virtio_pci_add_mem_cap(proxy, &common); -virtio_pci_add_mem_cap(proxy, &isr); -virtio_pci_add_mem_cap(proxy, &device); -virtio_pci_add_mem_cap(proxy, ¬ify.cap); virtio_add_feature(&vdev->host_features, VIRTIO_F_VERSION_1); memory_region_init(&proxy->modern_bar, OBJECT(proxy), "virtio-pci", 2 * QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * VIRTIO_QUEUE_MAX); virtio_pci_modern_regions_init(proxy); -virtio_pci_modern_region_map(proxy, &proxy->common); -virtio_pci_modern_region_map(proxy, &proxy->isr); -virtio_pci_modern_region_map(proxy, &proxy->device); -virtio_pci_modern_region_map(proxy, &proxy->notify); +virtio_pci_modern_region_map(proxy, &proxy->common, &common); +virtio_pci_modern_region_map(proxy, &proxy->isr, &isr); +virtio_pci_modern_region_map(proxy, &proxy->device, &device); +virtio_pci_modern_region_map(proxy, &proxy->notify, ¬ify.cap); pci_register_bar(&proxy->pci_dev, modern_mem_bar, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_PREFETCH | -- MST
[Qemu-devel] [PULL 17/42] virtio-pci: add flags to enable/disable legacy/modern
From: Gerd Hoffmann Add VIRTIO_PCI_FLAG_DISABLE_LEGACY and VIRTIO_PCI_FLAG_DISABLE_MODERN for VirtIOPCIProxy->flags. Also add properties for them. They can be used to disable modern (virtio 1.0) or legacy (virtio 0.9) modes. By default only legacy is advertized, modern will be turned on by default once all remaining spec compilance issues are addressed. Signed-off-by: Gerd Hoffmann Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.h | 6 ++ hw/virtio/virtio-pci.c | 46 +- 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h index 7a6481f..4e9b2db 100644 --- a/hw/virtio/virtio-pci.h +++ b/hw/virtio/virtio-pci.h @@ -63,6 +63,12 @@ typedef struct VirtioBusClass VirtioPCIBusClass; #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_LEGACY (1 << VIRTIO_PCI_FLAG_DISABLE_LEGACY_BIT) +#define VIRTIO_PCI_FLAG_DISABLE_MODERN (1 << VIRTIO_PCI_FLAG_DISABLE_MODERN_BIT) + typedef struct { MSIMessage msg; int virq; diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index d6d7668..37c4533 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1197,6 +1197,8 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) { VirtIOPCIProxy *proxy = VIRTIO_PCI(d); VirtioBusState *bus = &proxy->bus; +bool legacy = !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_LEGACY); +bool modern = !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN); uint8_t *config; uint32_t size; VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); @@ -1205,13 +1207,24 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) if (proxy->class_code) { pci_config_set_class(config, proxy->class_code); } -pci_set_word(config + PCI_SUBSYSTEM_VENDOR_ID, - pci_get_word(config + PCI_VENDOR_ID)); -pci_set_word(config + PCI_SUBSYSTEM_ID, virtio_bus_get_vdev_id(bus)); + +if (legacy) { +/* legacy and transitional */ +pci_set_word(config + PCI_SUBSYSTEM_VENDOR_ID, + pci_get_word(config + PCI_VENDOR_ID)); +pci_set_word(config + PCI_SUBSYSTEM_ID, virtio_bus_get_vdev_id(bus)); +} else { +/* pure virtio-1.0 */ +pci_set_word(config + PCI_VENDOR_ID, + PCI_VENDOR_ID_REDHAT_QUMRANET); +pci_set_word(config + PCI_DEVICE_ID, + 0x1040 + virtio_bus_get_vdev_id(bus)); +pci_config_set_revision(config, 1); +} config[PCI_INTERRUPT_PIN] = 1; -if (1) { /* TODO: Make this optional, dependent on virtio 1.0 */ +if (modern) { struct virtio_pci_cap common = { .cfg_type = VIRTIO_PCI_CAP_COMMON_CFG, .cap_len = sizeof common, @@ -1325,17 +1338,20 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) proxy->pci_dev.config_write = virtio_write_config; -size = VIRTIO_PCI_REGION_SIZE(&proxy->pci_dev) - + virtio_bus_get_vdev_config_len(bus); -if (size & (size - 1)) { -size = 1 << qemu_fls(size); -} +if (legacy) { +size = VIRTIO_PCI_REGION_SIZE(&proxy->pci_dev) ++ virtio_bus_get_vdev_config_len(bus); +if (size & (size - 1)) { +size = 1 << qemu_fls(size); +} -memory_region_init_io(&proxy->bar, OBJECT(proxy), &virtio_pci_config_ops, - proxy, "virtio-pci", size); +memory_region_init_io(&proxy->bar, OBJECT(proxy), + &virtio_pci_config_ops, + proxy, "virtio-pci", size); -pci_register_bar(&proxy->pci_dev, 0, PCI_BASE_ADDRESS_SPACE_IO, - &proxy->bar); +pci_register_bar(&proxy->pci_dev, 0, PCI_BASE_ADDRESS_SPACE_IO, + &proxy->bar); +} if (!kvm_has_many_ioeventfds()) { proxy->flags &= ~VIRTIO_PCI_FLAG_USE_IOEVENTFD; @@ -1379,6 +1395,10 @@ static void virtio_pci_reset(DeviceState *qdev) static Property virtio_pci_properties[] = { DEFINE_PROP_BIT("virtio-pci-bus-master-bug-migration", VirtIOPCIProxy, flags, VIRTIO_PCI_FLAG_BUS_MASTER_BUG_MIGRATION_BIT, false), +DEFINE_PROP_BIT("disable-legacy", VirtIOPCIProxy, flags, +VIRTIO_PCI_FLAG_DISABLE_LEGACY_BIT, false), +DEFINE_PROP_BIT("disable-modern", VirtIOPCIProxy, flags, +VIRTIO_PCI_FLAG_DISABLE_MODERN_BIT, true), DEFINE_PROP_END_OF_LIST(), }; -- MST
[Qemu-devel] [PULL 07/42] virtio-net: no writeable mac for virtio-1
From: Cornelia Huck Devices operating as virtio 1.0 may not allow writes to the mac address in config space. Signed-off-by: Cornelia Huck Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- hw/net/virtio-net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 0d3bf0f..e2d2ab5 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -87,6 +87,7 @@ static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *config) memcpy(&netcfg, config, n->config_size); if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_MAC_ADDR) && +!virtio_has_feature(vdev, VIRTIO_F_VERSION_1) && memcmp(netcfg.mac, n->mac, ETH_ALEN)) { memcpy(n->mac, netcfg.mac, ETH_ALEN); qemu_format_nic_info_str(qemu_get_queue(n->nic), n->mac); -- MST
[Qemu-devel] [PULL 16/42] virtio-pci: switch to modern accessors for 1.0
virtio 1.0 config space is in LE format for all devices, use modern wrappers when accessed through the 1.0 BAR. Reported-by: Rusty Russell Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 7805bdd..d6d7668 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1162,13 +1162,13 @@ static uint64_t virtio_pci_device_read(void *opaque, hwaddr addr, switch (size) { case 1: -val = virtio_config_readb(vdev, addr); +val = virtio_config_modern_readb(vdev, addr); break; case 2: -val = virtio_config_readw(vdev, addr); +val = virtio_config_modern_readw(vdev, addr); break; case 4: -val = virtio_config_readl(vdev, addr); +val = virtio_config_modern_readl(vdev, addr); break; } return val; @@ -1180,13 +1180,13 @@ static void virtio_pci_device_write(void *opaque, hwaddr addr, VirtIODevice *vdev = opaque; switch (size) { case 1: -virtio_config_writeb(vdev, addr, val); +virtio_config_modern_writeb(vdev, addr, val); break; case 2: -virtio_config_writew(vdev, addr, val); +virtio_config_modern_writew(vdev, addr, val); break; case 4: -virtio_config_writel(vdev, addr, val); +virtio_config_modern_writel(vdev, addr, val); break; } } -- MST
[Qemu-devel] [PULL 28/42] virtio-pci: move cap type to VirtIOPCIRegion
From: Gerd Hoffmann Signed-off-by: Gerd Hoffmann Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.h | 1 + hw/virtio/virtio-pci.c | 9 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h index f5829b0..ea1343d 100644 --- a/hw/virtio/virtio-pci.h +++ b/hw/virtio/virtio-pci.h @@ -94,6 +94,7 @@ typedef struct VirtioPCIClass { typedef struct VirtIOPCIRegion { MemoryRegion mr; uint32_t offset; +uint32_t type; } VirtIOPCIRegion; struct VirtIOPCIProxy { diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index f4bdd1c..440db10 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1252,18 +1252,21 @@ static void virtio_pci_modern_regions_init(VirtIOPCIProxy *proxy) proxy, "virtio-pci-common", 0x1000); proxy->common.offset = 0x0; +proxy->common.type = VIRTIO_PCI_CAP_COMMON_CFG; memory_region_init_io(&proxy->isr.mr, OBJECT(proxy), &isr_ops, proxy, "virtio-pci-isr", 0x1000); proxy->isr.offset = 0x1000; +proxy->isr.type = VIRTIO_PCI_CAP_ISR_CFG; memory_region_init_io(&proxy->device.mr, OBJECT(proxy), &device_ops, virtio_bus_get_device(&proxy->bus), "virtio-pci-device", 0x1000); proxy->device.offset = 0x2000; +proxy->device.type = VIRTIO_PCI_CAP_DEVICE_CFG; memory_region_init_io(&proxy->notify.mr, OBJECT(proxy), ¬ify_ops, @@ -1272,6 +1275,7 @@ static void virtio_pci_modern_regions_init(VirtIOPCIProxy *proxy) QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * VIRTIO_QUEUE_MAX); proxy->notify.offset = 0x3000; +proxy->notify.type = VIRTIO_PCI_CAP_NOTIFY_CFG; } static void virtio_pci_modern_region_map(VirtIOPCIProxy *proxy, @@ -1282,6 +1286,7 @@ static void virtio_pci_modern_region_map(VirtIOPCIProxy *proxy, region->offset, ®ion->mr); +cap->cfg_type = region->type; cap->offset = cpu_to_le32(region->offset); cap->length = cpu_to_le32(memory_region_size(®ion->mr)); virtio_pci_add_mem_cap(proxy, cap); @@ -1337,22 +1342,18 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) if (modern) { struct virtio_pci_cap common = { -.cfg_type = VIRTIO_PCI_CAP_COMMON_CFG, .cap_len = sizeof common, .bar = modern_mem_bar, }; struct virtio_pci_cap isr = { -.cfg_type = VIRTIO_PCI_CAP_ISR_CFG, .cap_len = sizeof isr, .bar = modern_mem_bar, }; struct virtio_pci_cap device = { -.cfg_type = VIRTIO_PCI_CAP_DEVICE_CFG, .cap_len = sizeof device, .bar = modern_mem_bar, }; struct virtio_pci_notify_cap notify = { -.cap.cfg_type = VIRTIO_PCI_CAP_NOTIFY_CFG, .cap.cap_len = sizeof notify, .cap.bar = modern_mem_bar, .notify_off_multiplier = -- MST
[Qemu-devel] [PULL 18/42] virtio-pci: make QEMU_VIRTIO_PCI_QUEUE_MEM_MULT smaller
From: Gerd Hoffmann Signed-off-by: Gerd Hoffmann Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 37c4533..9481584 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -936,7 +936,7 @@ static void virtio_pci_add_mem_cap(VirtIOPCIProxy *proxy, cap->cap_len - PCI_CAP_FLAGS); } -#define QEMU_VIRTIO_PCI_QUEUE_MEM_MULT 0x1 +#define QEMU_VIRTIO_PCI_QUEUE_MEM_MULT 0x1000 static uint64_t virtio_pci_common_read(void *opaque, hwaddr addr, unsigned size) -- MST
[Qemu-devel] [PULL 11/42] vhost: 64 bit features
From: Cornelia Huck Make sure that all vhost interfaces use 64 bit features, as the virtio core does, and make sure to use ULL everywhere possible to be on the safe side. Signed-off-by: Cornelia Huck Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- include/hw/virtio/vhost.h | 6 +++--- include/net/vhost_net.h | 4 ++-- hw/net/vhost_net.c| 12 ++-- hw/virtio/vhost.c | 14 +++--- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 816a2e8..84f170e 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -78,8 +78,8 @@ bool vhost_virtqueue_pending(struct vhost_dev *hdev, int n); */ void vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int n, bool mask); -unsigned vhost_get_features(struct vhost_dev *hdev, const int *feature_bits, -unsigned features); +uint64_t vhost_get_features(struct vhost_dev *hdev, const int *feature_bits, +uint64_t features); void vhost_ack_features(struct vhost_dev *hdev, const int *feature_bits, -unsigned features); +uint64_t features); #endif diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h index b1c18a3..9eb493e 100644 --- a/include/net/vhost_net.h +++ b/include/net/vhost_net.h @@ -22,8 +22,8 @@ void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs, int total_queues); void vhost_net_cleanup(VHostNetState *net); -unsigned vhost_net_get_features(VHostNetState *net, unsigned features); -void vhost_net_ack_features(VHostNetState *net, unsigned features); +uint64_t vhost_net_get_features(VHostNetState *net, uint64_t features); +void vhost_net_ack_features(VHostNetState *net, uint64_t features); bool vhost_net_virtqueue_pending(VHostNetState *net, int n); void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev, diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index dc48ece..1c55517 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -109,13 +109,13 @@ static const int *vhost_net_get_feature_bits(struct vhost_net *net) return feature_bits; } -unsigned vhost_net_get_features(struct vhost_net *net, unsigned features) +uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features) { return vhost_get_features(&net->dev, vhost_net_get_feature_bits(net), features); } -void vhost_net_ack_features(struct vhost_net *net, unsigned features) +void vhost_net_ack_features(struct vhost_net *net, uint64_t features) { net->dev.acked_features = net->dev.backend_features; vhost_ack_features(&net->dev, vhost_net_get_feature_bits(net), features); @@ -149,7 +149,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options) goto fail; } net->dev.backend_features = qemu_has_vnet_hdr(options->net_backend) -? 0 : (1 << VHOST_NET_F_VIRTIO_NET_HDR); +? 0 : (1ULL << VHOST_NET_F_VIRTIO_NET_HDR); net->backend = r; } else { net->dev.backend_features = 0; @@ -169,7 +169,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options) if (backend_kernel) { if (!qemu_has_vnet_hdr_len(options->net_backend, sizeof(struct virtio_net_hdr_mrg_rxbuf))) { -net->dev.features &= ~(1 << VIRTIO_NET_F_MRG_RXBUF); +net->dev.features &= ~(1ULL << VIRTIO_NET_F_MRG_RXBUF); } if (~net->dev.features & net->dev.backend_features) { fprintf(stderr, "vhost lacks feature mask %" PRIu64 @@ -433,11 +433,11 @@ void vhost_net_cleanup(struct vhost_net *net) { } -unsigned vhost_net_get_features(struct vhost_net *net, unsigned features) +uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features) { return features; } -void vhost_net_ack_features(struct vhost_net *net, unsigned features) +void vhost_net_ack_features(struct vhost_net *net, uint64_t features) { } diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 3a52a4d..7908255 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -590,7 +590,7 @@ static int vhost_dev_set_features(struct vhost_dev *dev, bool enable_log) uint64_t features = dev->acked_features; int r; if (enable_log) { -features |= 0x1 << VHOST_F_LOG_ALL; +features |= 0x1ULL << VHOST_F_LOG_ALL; } r = dev->vhost_ops->vhost_call(dev, VHOST_SET_FEATURES, &features); return r < 0 ? -errno : 0; @@ -899,7 +899,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque, .priority = 10 }; hdev->migration_blocker = NULL; -if (!(hdev->features & (0x1 << VHOST_F_LOG_ALL))) { +if (!(hdev->features & (0x1ULL << VHOST_F_LOG_ALL))) { error_setg(&hdev->migration_blocker, "Migration disabled: vhost lacks VHOST_F_LOG_ALL feature.");
[Qemu-devel] [PULL 29/42] virtio-pci: drop identical virtio_pci_cap
From: Gerd Hoffmann Now the three struct virtio_pci_caps are identical, lets drop two of them ;) Signed-off-by: Gerd Hoffmann Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.c | 18 +- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 440db10..771bbd5 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1341,16 +1341,8 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) if (modern) { -struct virtio_pci_cap common = { -.cap_len = sizeof common, -.bar = modern_mem_bar, -}; -struct virtio_pci_cap isr = { -.cap_len = sizeof isr, -.bar = modern_mem_bar, -}; -struct virtio_pci_cap device = { -.cap_len = sizeof device, +struct virtio_pci_cap cap = { +.cap_len = sizeof cap, .bar = modern_mem_bar, }; struct virtio_pci_notify_cap notify = { @@ -1367,9 +1359,9 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) 2 * QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * VIRTIO_QUEUE_MAX); virtio_pci_modern_regions_init(proxy); -virtio_pci_modern_region_map(proxy, &proxy->common, &common); -virtio_pci_modern_region_map(proxy, &proxy->isr, &isr); -virtio_pci_modern_region_map(proxy, &proxy->device, &device); +virtio_pci_modern_region_map(proxy, &proxy->common, &cap); +virtio_pci_modern_region_map(proxy, &proxy->isr, &cap); +virtio_pci_modern_region_map(proxy, &proxy->device, &cap); virtio_pci_modern_region_map(proxy, &proxy->notify, ¬ify.cap); pci_register_bar(&proxy->pci_dev, modern_mem_bar, PCI_BASE_ADDRESS_SPACE_MEMORY | -- MST
[Qemu-devel] [PULL 22/42] virtio_balloon: header update
add modern header Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- include/hw/virtio/virtio-balloon.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/include/hw/virtio/virtio-balloon.h b/include/hw/virtio/virtio-balloon.h index 4ab8f54..346a9fd 100644 --- a/include/hw/virtio/virtio-balloon.h +++ b/include/hw/virtio/virtio-balloon.h @@ -25,6 +25,12 @@ typedef struct virtio_balloon_stat VirtIOBalloonStat; +typedef struct virtio_balloon_stat_modern { + uint16_t tag; + uint8_t reserved[6]; + uint64_t val; +} VirtIOBalloonStatModern; + typedef struct VirtIOBalloon { VirtIODevice parent_obj; VirtQueue *ivq, *dvq, *svq; -- MST
[Qemu-devel] [PULL 03/42] virtio: allow virtio-1 queue layout
From: Cornelia Huck For virtio-1 devices, we allow a more complex queue layout that doesn't require descriptor table and rings on a physically-contigous memory area: add virtio_queue_set_rings() to allow transports to set this up. Signed-off-by: Cornelia Huck Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 3 +++ hw/virtio/virtio-mmio.c| 3 +++ hw/virtio/virtio.c | 53 +- 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 13e8549..b877a93 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -177,6 +177,9 @@ hwaddr virtio_queue_get_addr(VirtIODevice *vdev, int n); void virtio_queue_set_num(VirtIODevice *vdev, int n, int num); int virtio_queue_get_num(VirtIODevice *vdev, int n); int virtio_get_num_queues(VirtIODevice *vdev); +void virtio_queue_set_rings(VirtIODevice *vdev, int n, hwaddr desc, +hwaddr avail, hwaddr used); +void virtio_queue_update_rings(VirtIODevice *vdev, int n); void virtio_queue_set_align(VirtIODevice *vdev, int n, int align); void virtio_queue_notify(VirtIODevice *vdev, int n); uint16_t virtio_queue_vector(VirtIODevice *vdev, int n); diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index c8f7294..18660b0 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -333,8 +333,11 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value, case VIRTIO_MMIO_QUEUENUM: DPRINTF("mmio_queue write %d max %d\n", (int)value, VIRTQUEUE_MAX_SIZE); virtio_queue_set_num(vdev, vdev->queue_sel, value); +/* Note: only call this function for legacy devices */ +virtio_queue_update_rings(vdev, vdev->queue_sel); break; case VIRTIO_MMIO_QUEUEALIGN: +/* Note: this is only valid for legacy devices */ virtio_queue_set_align(vdev, vdev->queue_sel, value); break; case VIRTIO_MMIO_QUEUEPFN: diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index d37d27b..c27e975 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -69,7 +69,6 @@ typedef struct VRing struct VirtQueue { VRing vring; -hwaddr pa; uint16_t last_avail_idx; /* Last used index value we have signalled on */ uint16_t signalled_used; @@ -93,15 +92,18 @@ struct VirtQueue }; /* virt queue functions */ -static void virtqueue_init(VirtQueue *vq) +void virtio_queue_update_rings(VirtIODevice *vdev, int n) { -hwaddr pa = vq->pa; +VRing *vring = &vdev->vq[n].vring; -vq->vring.desc = pa; -vq->vring.avail = pa + vq->vring.num * sizeof(VRingDesc); -vq->vring.used = vring_align(vq->vring.avail + - offsetof(VRingAvail, ring[vq->vring.num]), - vq->vring.align); +if (!vring->desc) { +/* not yet setup -> nothing to do */ +return; +} +vring->avail = vring->desc + vring->num * sizeof(VRingDesc); +vring->used = vring_align(vring->avail + + offsetof(VRingAvail, ring[vring->num]), + vring->align); } static inline uint64_t vring_desc_addr(VirtIODevice *vdev, hwaddr desc_pa, @@ -605,7 +607,6 @@ void virtio_reset(void *opaque) vdev->vq[i].vring.avail = 0; vdev->vq[i].vring.used = 0; vdev->vq[i].last_avail_idx = 0; -vdev->vq[i].pa = 0; virtio_queue_set_vector(vdev, i, VIRTIO_NO_VECTOR); vdev->vq[i].signalled_used = 0; vdev->vq[i].signalled_used_valid = false; @@ -708,13 +709,21 @@ void virtio_config_writel(VirtIODevice *vdev, uint32_t addr, uint32_t data) void virtio_queue_set_addr(VirtIODevice *vdev, int n, hwaddr addr) { -vdev->vq[n].pa = addr; -virtqueue_init(&vdev->vq[n]); +vdev->vq[n].vring.desc = addr; +virtio_queue_update_rings(vdev, n); } hwaddr virtio_queue_get_addr(VirtIODevice *vdev, int n) { -return vdev->vq[n].pa; +return vdev->vq[n].vring.desc; +} + +void virtio_queue_set_rings(VirtIODevice *vdev, int n, hwaddr desc, +hwaddr avail, hwaddr used) +{ +vdev->vq[n].vring.desc = desc; +vdev->vq[n].vring.avail = avail; +vdev->vq[n].vring.used = used; } void virtio_queue_set_num(VirtIODevice *vdev, int n, int num) @@ -728,7 +737,6 @@ void virtio_queue_set_num(VirtIODevice *vdev, int n, int num) return; } vdev->vq[n].vring.num = num; -virtqueue_init(&vdev->vq[n]); } VirtQueue *virtio_vector_first_queue(VirtIODevice *vdev, uint16_t vector) @@ -771,6 +779,11 @@ void virtio_queue_set_align(VirtIODevice *vdev, int n, int align) BusState *qbus = qdev_get_parent_bus(DEVICE(vdev)); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); +/* virtio-1 compliant devices cannot change the alignment
[Qemu-devel] [PULL 31/42] pci: add PCI_CLASS_INPUT_*
From: Gerd Hoffmann Signed-off-by: Gerd Hoffmann Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci_ids.h | 7 +++ 1 file changed, 7 insertions(+) diff --git a/include/hw/pci/pci_ids.h b/include/hw/pci/pci_ids.h index c6de710..49c062b 100644 --- a/include/hw/pci/pci_ids.h +++ b/include/hw/pci/pci_ids.h @@ -47,6 +47,13 @@ #define PCI_CLASS_COMMUNICATION_SERIAL 0x0700 #define PCI_CLASS_COMMUNICATION_OTHER0x0780 +#define PCI_CLASS_INPUT_KEYBOARD 0x0900 +#define PCI_CLASS_INPUT_PEN 0x0901 +#define PCI_CLASS_INPUT_MOUSE0x0902 +#define PCI_CLASS_INPUT_SCANNER 0x0903 +#define PCI_CLASS_INPUT_GAMEPORT 0x0904 +#define PCI_CLASS_INPUT_OTHER0x0980 + #define PCI_CLASS_PROCESSOR_CO 0x0b40 #define PCI_CLASS_PROCESSOR_POWERPC 0x0b20 -- MST
[Qemu-devel] [PULL 33/42] virtio-input: emulated devices [pci]
From: Gerd Hoffmann This patch adds virtio-pci support for the emulated virtio-input devices. Using them is as simple as adding "-device virtio-tablet-pci" to your command line. If you want add multiple devices but don't want waste a pci slot for each you can compose a multifunction device this way: qemu -device virtio-keyboard-pci,addr=0d.0,multifunction=on \ -device virtio-tablet-pci,addr=0d.1,multifunction=on Signed-off-by: Gerd Hoffmann Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.h | 13 hw/virtio/virtio-pci.c | 84 ++ 2 files changed, 97 insertions(+) diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h index 754971f..d962125 100644 --- a/hw/virtio/virtio-pci.h +++ b/hw/virtio/virtio-pci.h @@ -41,6 +41,7 @@ typedef struct VirtIONetPCI VirtIONetPCI; typedef struct VHostSCSIPCI VHostSCSIPCI; typedef struct VirtIORngPCI VirtIORngPCI; typedef struct VirtIOInputPCI VirtIOInputPCI; +typedef struct VirtIOInputHIDPCI VirtIOInputHIDPCI; /* virtio-pci-bus */ @@ -248,6 +249,18 @@ struct VirtIOInputPCI { VirtIOInput vdev; }; +#define TYPE_VIRTIO_INPUT_HID_PCI "virtio-input-hid-pci" +#define TYPE_VIRTIO_KEYBOARD_PCI "virtio-keyboard-pci" +#define TYPE_VIRTIO_MOUSE_PCI "virtio-mouse-pci" +#define TYPE_VIRTIO_TABLET_PCI"virtio-tablet-pci" +#define VIRTIO_INPUT_HID_PCI(obj) \ +OBJECT_CHECK(VirtIOInputHIDPCI, (obj), TYPE_VIRTIO_INPUT_HID_PCI) + +struct VirtIOInputHIDPCI { +VirtIOPCIProxy parent_obj; +VirtIOInputHID vdev; +}; + /* Virtio ABI version, if we increment this, we break the guest driver. */ #define VIRTIO_PCI_ABI_VERSION 0 diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 8ec741b..d7cf34c 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1900,6 +1900,12 @@ static const TypeInfo virtio_rng_pci_info = { /* virtio-input-pci */ +static Property virtio_input_hid_pci_properties[] = { +DEFINE_VIRTIO_INPUT_PROPERTIES(VirtIOInputPCI, vdev.input), +DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2), +DEFINE_PROP_END_OF_LIST(), +}; + static void virtio_input_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) { VirtIOInputPCI *vinput = VIRTIO_INPUT_PCI(vpci_dev); @@ -1924,6 +1930,49 @@ static void virtio_input_pci_class_init(ObjectClass *klass, void *data) pcidev_k->class_id = PCI_CLASS_INPUT_OTHER; } +static void virtio_input_hid_pci_class_init(ObjectClass *klass, void *data) +{ +DeviceClass *dc = DEVICE_CLASS(klass); + +dc->props = virtio_input_hid_pci_properties; +} + +static void virtio_input_hid_kbd_pci_class_init(ObjectClass *klass, void *data) +{ +PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass); + +pcidev_k->class_id = PCI_CLASS_INPUT_KEYBOARD; +} + +static void virtio_input_hid_mouse_pci_class_init(ObjectClass *klass, + void *data) +{ +PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass); + +pcidev_k->class_id = PCI_CLASS_INPUT_MOUSE; +} + +static void virtio_keyboard_initfn(Object *obj) +{ +VirtIOInputHIDPCI *dev = VIRTIO_INPUT_HID_PCI(obj); +object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_KEYBOARD); +object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); +} + +static void virtio_mouse_initfn(Object *obj) +{ +VirtIOInputHIDPCI *dev = VIRTIO_INPUT_HID_PCI(obj); +object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_MOUSE); +object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); +} + +static void virtio_tablet_initfn(Object *obj) +{ +VirtIOInputHIDPCI *dev = VIRTIO_INPUT_HID_PCI(obj); +object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_TABLET); +object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); +} + static const TypeInfo virtio_input_pci_info = { .name = TYPE_VIRTIO_INPUT_PCI, .parent= TYPE_VIRTIO_PCI, @@ -1932,6 +1981,37 @@ static const TypeInfo virtio_input_pci_info = { .abstract = true, }; +static const TypeInfo virtio_input_hid_pci_info = { +.name = TYPE_VIRTIO_INPUT_HID_PCI, +.parent= TYPE_VIRTIO_INPUT_PCI, +.instance_size = sizeof(VirtIOInputHIDPCI), +.class_init= virtio_input_hid_pci_class_init, +.abstract = true, +}; + +static const TypeInfo virtio_keyboard_pci_info = { +.name = TYPE_VIRTIO_KEYBOARD_PCI, +.parent= TYPE_VIRTIO_INPUT_HID_PCI, +.class_init= virtio_input_hid_kbd_pci_class_init, +.instance_size = sizeof(VirtIOInputHIDPCI), +.instance_init = virtio_keyboard_initfn, +}; + +static const TypeInfo virtio_mouse_pci_info = { +.name = TYPE_VIRTIO_MOUSE_PCI, +.parent= TYPE_VIRTIO_INPUT_HID_PCI, +.class_init= virtio_input_hid_mouse_pci_class_init, +.instance_size = sizeof(VirtIOInpu
[Qemu-devel] [PULL 35/42] virtio-net.h: Remove unsed DEFINE_VIRTIO_NET_PROPERTIES
From: Shannon Zhao Remove unsed DEFINE_VIRTIO_NET_PROPERTIES in virtio-net.h and delete a space typo. Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao Reviewed-by: Paolo Bonzini Acked-by: Cornelia Huck Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-net.h | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index c142b42..280dacf 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -107,12 +107,7 @@ typedef struct VirtIONet { * VIRTIO_NET_F_CTRL_GUEST_OFFLOADS feature bit. */ #define VIRTIO_NET_CTRL_GUEST_OFFLOADS 5 - #define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET0 - -#define DEFINE_VIRTIO_NET_PROPERTIES(_state, _field) \ -DEFINE_PROP_UINT32("x-txtimer", _state, _field.txtimer, TX_TIMER_INTERVAL),\ -DEFINE_PROP_INT32("x-txburst", _state, _field.txburst, TX_BURST), \ -DEFINE_PROP_STRING("tx", _state, _field.tx) +#define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET0 void virtio_net_set_netclient_name(VirtIONet *n, const char *name, const char *type); -- MST
[Qemu-devel] [PULL 24/42] virtio-pci: add struct VirtIOPCIRegion for virtio-1 regions
From: Gerd Hoffmann For now just place the MemoryRegion there, following patches will add more. Signed-off-by: Gerd Hoffmann Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.h | 12 hw/virtio/virtio-pci.c | 20 +++- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h index 4e9b2db..8f1fc02 100644 --- a/hw/virtio/virtio-pci.h +++ b/hw/virtio/virtio-pci.h @@ -91,13 +91,17 @@ typedef struct VirtioPCIClass { void (*realize)(VirtIOPCIProxy *vpci_dev, Error **errp); } VirtioPCIClass; +typedef struct VirtIOPCIRegion { +MemoryRegion mr; +} VirtIOPCIRegion; + struct VirtIOPCIProxy { PCIDevice pci_dev; MemoryRegion bar; -MemoryRegion common; -MemoryRegion isr; -MemoryRegion device; -MemoryRegion notify; +VirtIOPCIRegion common; +VirtIOPCIRegion isr; +VirtIOPCIRegion device; +VirtIOPCIRegion notify; MemoryRegion modern_bar; uint32_t flags; uint32_t class_code; diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index b7beddd..ebba2d1 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -145,7 +145,7 @@ static int virtio_pci_set_host_notifier_internal(VirtIOPCIProxy *proxy, EventNotifier *notifier = virtio_queue_get_host_notifier(vq); bool legacy = !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_LEGACY); bool modern = !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN); -MemoryRegion *modern_mr = &proxy->notify; +MemoryRegion *modern_mr = &proxy->notify.mr; MemoryRegion *legacy_mr = &proxy->bar; hwaddr modern_addr = QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * virtio_get_queue_index(vq); @@ -1340,28 +1340,30 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) memory_region_init(&proxy->modern_bar, OBJECT(proxy), "virtio-pci", 2 * QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * VIRTIO_QUEUE_MAX); -memory_region_init_io(&proxy->common, OBJECT(proxy), +memory_region_init_io(&proxy->common.mr, OBJECT(proxy), &common_ops, proxy, "virtio-pci-common", 0x1000); -memory_region_add_subregion(&proxy->modern_bar, 0, &proxy->common); -memory_region_init_io(&proxy->isr, OBJECT(proxy), +memory_region_add_subregion(&proxy->modern_bar, 0, &proxy->common.mr); +memory_region_init_io(&proxy->isr.mr, OBJECT(proxy), &isr_ops, proxy, "virtio-pci-isr", 0x1000); -memory_region_add_subregion(&proxy->modern_bar, 0x1000, &proxy->isr); -memory_region_init_io(&proxy->device, OBJECT(proxy), +memory_region_add_subregion(&proxy->modern_bar, 0x1000, &proxy->isr.mr); +memory_region_init_io(&proxy->device.mr, OBJECT(proxy), &device_ops, virtio_bus_get_device(&proxy->bus), "virtio-pci-device", 0x1000); -memory_region_add_subregion(&proxy->modern_bar, 0x2000, &proxy->device); -memory_region_init_io(&proxy->notify, OBJECT(proxy), +memory_region_add_subregion(&proxy->modern_bar, 0x2000, +&proxy->device.mr); +memory_region_init_io(&proxy->notify.mr, OBJECT(proxy), ¬ify_ops, virtio_bus_get_device(&proxy->bus), "virtio-pci-notify", QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * VIRTIO_QUEUE_MAX); -memory_region_add_subregion(&proxy->modern_bar, 0x3000, &proxy->notify); +memory_region_add_subregion(&proxy->modern_bar, 0x3000, +&proxy->notify.mr); pci_register_bar(&proxy->pci_dev, modern_mem_bar, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_PREFETCH | -- MST
[Qemu-devel] [PULL 23/42] virtio-balloon: switch to virtio_add_feature
From: Cornelia Huck This was missed during the conversion of feature bit manipulation. Signed-off-by: Cornelia Huck Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- hw/virtio/virtio-balloon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index f915c7b..78bc14f 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -312,7 +312,7 @@ static void virtio_balloon_set_config(VirtIODevice *vdev, static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f) { -f |= (1 << VIRTIO_BALLOON_F_STATS_VQ); +virtio_add_feature(&f, VIRTIO_BALLOON_F_STATS_VQ); return f; } -- MST
[Qemu-devel] [PULL 25/42] virtio-pci: add virtio_pci_modern_regions_init()
From: Gerd Hoffmann Add init function for the modern pci regions, move over the init code. Signed-off-by: Gerd Hoffmann Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.c | 117 + 1 file changed, 59 insertions(+), 58 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index ebba2d1..090e95b 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1208,6 +1208,64 @@ static void virtio_pci_device_write(void *opaque, hwaddr addr, } } +static void virtio_pci_modern_regions_init(VirtIOPCIProxy *proxy) +{ +static const MemoryRegionOps common_ops = { +.read = virtio_pci_common_read, +.write = virtio_pci_common_write, +.impl = { +.min_access_size = 1, +.max_access_size = 4, +}, +.endianness = DEVICE_LITTLE_ENDIAN, +}; +static const MemoryRegionOps isr_ops = { +.read = virtio_pci_isr_read, +.write = virtio_pci_isr_write, +.impl = { +.min_access_size = 1, +.max_access_size = 4, +}, +.endianness = DEVICE_LITTLE_ENDIAN, +}; +static const MemoryRegionOps device_ops = { +.read = virtio_pci_device_read, +.write = virtio_pci_device_write, +.impl = { +.min_access_size = 1, +.max_access_size = 4, +}, +.endianness = DEVICE_LITTLE_ENDIAN, +}; +static const MemoryRegionOps notify_ops = { +.read = virtio_pci_notify_read, +.write = virtio_pci_notify_write, +.impl = { +.min_access_size = 1, +.max_access_size = 4, +}, +.endianness = DEVICE_LITTLE_ENDIAN, +}; + +memory_region_init_io(&proxy->common.mr, OBJECT(proxy), + &common_ops, + proxy, + "virtio-pci-common", 0x1000); +memory_region_init_io(&proxy->isr.mr, OBJECT(proxy), + &isr_ops, + proxy, + "virtio-pci-isr", 0x1000); +memory_region_init_io(&proxy->device.mr, OBJECT(proxy), + &device_ops, + virtio_bus_get_device(&proxy->bus), + "virtio-pci-device", 0x1000); +memory_region_init_io(&proxy->notify.mr, OBJECT(proxy), + ¬ify_ops, + virtio_bus_get_device(&proxy->bus), + "virtio-pci-notify", + QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * + VIRTIO_QUEUE_MAX); +} /* This is called by virtio-bus just after the device is plugged. */ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) @@ -1290,46 +1348,6 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) cpu_to_le32(QEMU_VIRTIO_PCI_QUEUE_MEM_MULT), }; -static const MemoryRegionOps common_ops = { -.read = virtio_pci_common_read, -.write = virtio_pci_common_write, -.impl = { -.min_access_size = 1, -.max_access_size = 4, -}, -.endianness = DEVICE_LITTLE_ENDIAN, -}; - -static const MemoryRegionOps isr_ops = { -.read = virtio_pci_isr_read, -.write = virtio_pci_isr_write, -.impl = { -.min_access_size = 1, -.max_access_size = 4, -}, -.endianness = DEVICE_LITTLE_ENDIAN, -}; - -static const MemoryRegionOps device_ops = { -.read = virtio_pci_device_read, -.write = virtio_pci_device_write, -.impl = { -.min_access_size = 1, -.max_access_size = 4, -}, -.endianness = DEVICE_LITTLE_ENDIAN, -}; - -static const MemoryRegionOps notify_ops = { -.read = virtio_pci_notify_read, -.write = virtio_pci_notify_write, -.impl = { -.min_access_size = 1, -.max_access_size = 4, -}, -.endianness = DEVICE_LITTLE_ENDIAN, -}; - /* TODO: add io access for speed */ virtio_pci_add_mem_cap(proxy, &common); virtio_pci_add_mem_cap(proxy, &isr); @@ -1340,28 +1358,11 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) memory_region_init(&proxy->modern_bar, OBJECT(proxy), "virtio-pci", 2 * QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * VIRTIO_QUEUE_MAX); -memory_region_init_io(&proxy->common.mr, OBJECT(proxy), - &common_ops, - proxy, - "virtio-pci-common", 0x1000); +virtio_pci_modern_regions_init(proxy); memory_regi
[Qemu-devel] [PULL 36/42] virtio-scsi: move qdev properties into virtio-scsi.c
From: Shannon Zhao As only one place in virtio-scsi.c uses DEFINE_VIRTIO_SCSI_PROPERTIES and DEFINE_VIRTIO_SCSI_FEATURES, there is no need to expose them. Inline them into virtio-scsi.c to avoid wrongly use. Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao Reviewed-by: Paolo Bonzini Acked-by: Cornelia Huck Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-scsi.h | 13 - hw/scsi/virtio-scsi.c | 13 +++-- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h index b42e7f1..088fe9f 100644 --- a/include/hw/virtio/virtio-scsi.h +++ b/include/hw/virtio/virtio-scsi.h @@ -141,19 +141,6 @@ typedef struct VirtIOSCSIReq { } req; } VirtIOSCSIReq; -#define DEFINE_VIRTIO_SCSI_PROPERTIES(_state, _conf_field) \ -DEFINE_PROP_UINT32("num_queues", _state, _conf_field.num_queues, 1), \ -DEFINE_PROP_UINT32("max_sectors", _state, _conf_field.max_sectors, 0x),\ -DEFINE_PROP_UINT32("cmd_per_lun", _state, _conf_field.cmd_per_lun, 128) - -#define DEFINE_VIRTIO_SCSI_FEATURES(_state, _feature_field) \ -DEFINE_PROP_BIT("any_layout", _state, _feature_field, \ -VIRTIO_F_ANY_LAYOUT, true), \ -DEFINE_PROP_BIT("hotplug", _state, _feature_field, VIRTIO_SCSI_F_HOTPLUG, \ - true), \ -DEFINE_PROP_BIT("param_change", _state, _feature_field, \ -VIRTIO_SCSI_F_CHANGE, true) - typedef void (*HandleOutput)(VirtIODevice *, VirtQueue *); void virtio_scsi_common_realize(DeviceState *dev, Error **errp, diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index b0dee29..f7d3c7c 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -948,8 +948,17 @@ static void virtio_scsi_device_unrealize(DeviceState *dev, Error **errp) } static Property virtio_scsi_properties[] = { -DEFINE_VIRTIO_SCSI_PROPERTIES(VirtIOSCSI, parent_obj.conf), -DEFINE_VIRTIO_SCSI_FEATURES(VirtIOSCSI, host_features), +DEFINE_PROP_UINT32("num_queues", VirtIOSCSI, parent_obj.conf.num_queues, 1), +DEFINE_PROP_UINT32("max_sectors", VirtIOSCSI, parent_obj.conf.max_sectors, + 0x), +DEFINE_PROP_UINT32("cmd_per_lun", VirtIOSCSI, parent_obj.conf.cmd_per_lun, + 128), +DEFINE_PROP_BIT("any_layout", VirtIOSCSI, host_features, + VIRTIO_F_ANY_LAYOUT, true), +DEFINE_PROP_BIT("hotplug", VirtIOSCSI, host_features, + VIRTIO_SCSI_F_HOTPLUG, true), +DEFINE_PROP_BIT("param_change", VirtIOSCSI, host_features, +VIRTIO_SCSI_F_CHANGE, true), DEFINE_PROP_END_OF_LIST(), }; -- MST
[Qemu-devel] [PULL 41/42] i386/acpi-build: more traditional _UID and _HID for PXB root buses
From: Laszlo Ersek The ACPI specification permits the _HID and _UID objects to evaluate to strings. (See "6.1.5 _HID (Hardware ID)" and "6.1.12 _UID (Unique ID)" in the ACPI v6.0 spec.) With regard to related standards, the UEFI specification can also express a device address composed from string _HID and _UID identifiers, inside the Expanded ACPI Device Path Node. (See "9.3.3 ACPI Device Path", Table 49, in the UEFI v2.5 spec.) However, numeric (integer) contents for both _HID and _UID are more traditional. They are recommended by the UEFI spec for size reasons: [...] the ACPI Device Path node is smaller and should be used if possible to reduce the size of device paths that may potentially be stored in nonvolatile storage [...] External tools support them better (for example the --acpi_hid and --acpi_uid options of "efibootmgr" only take numeric identifiers). Finally, numeric _HID and _UID contents are existing practice in the QEMU source. This patch was tested with a Fedora 20 LiveCD and a preexistent Windows Server 2012 R2 guest. Using "acpidump" and "iasl" in the Fedora guest, we get, in the SSDT: > Scope (\_SB) > { > Device (PC04) > { > Name (_UID, 0x04) // _UID: Unique ID > Name (_HID, EisaId ("PNP0A03") /* PCI Bus */) // _HID: Hardware ID Cc: Marcel Apfelbaum Cc: Michael S. Tsirkin Signed-off-by: Laszlo Ersek Reviewed-by: Marcel Apfelbaum Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/acpi-build.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index db32fd1..8fae3b9 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -944,9 +944,8 @@ build_ssdt(GArray *table_data, GArray *linker, scope = aml_scope("\\_SB"); dev = aml_device("PC%.02X", bus_num); -aml_append(dev, - aml_name_decl("_UID", aml_string("PC%.02X", bus_num))); -aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A03"))); +aml_append(dev, aml_name_decl("_UID", aml_int(bus_num))); +aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A03"))); aml_append(dev, aml_name_decl("_BBN", aml_int(bus_num))); if (numa_node != NUMA_NODE_UNASSIGNED) { -- MST
[Qemu-devel] [PULL 40/42] vhost-scsi: move qdev properties into vhost-scsi.c
From: Shannon Zhao As only one place in vhost-scsi.c uses DEFINE_VHOST_SCSI_PROPERTIES, there is no need to expose it. Inline it into vhost-scsi.c to avoid wrongly use. Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao Reviewed-by: Paolo Bonzini Acked-by: Cornelia Huck Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-scsi.h | 9 - hw/scsi/vhost-scsi.c | 9 - 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/include/hw/virtio/vhost-scsi.h b/include/hw/virtio/vhost-scsi.h index dea0075..701bfee 100644 --- a/include/hw/virtio/vhost-scsi.h +++ b/include/hw/virtio/vhost-scsi.h @@ -66,13 +66,4 @@ typedef struct VHostSCSI { int lun; } VHostSCSI; -#define DEFINE_VHOST_SCSI_PROPERTIES(_state, _conf_field) \ -DEFINE_PROP_STRING("vhostfd", _state, _conf_field.vhostfd), \ -DEFINE_PROP_STRING("wwpn", _state, _conf_field.wwpn), \ -DEFINE_PROP_UINT32("boot_tpgt", _state, _conf_field.boot_tpgt, 0), \ -DEFINE_PROP_UINT32("num_queues", _state, _conf_field.num_queues, 1), \ -DEFINE_PROP_UINT32("max_sectors", _state, _conf_field.max_sectors, 0x), \ -DEFINE_PROP_UINT32("cmd_per_lun", _state, _conf_field.cmd_per_lun, 128) - - #endif diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 9c76486..1941aa1 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -294,7 +294,14 @@ static char *vhost_scsi_get_fw_dev_path(FWPathProvider *p, BusState *bus, } static Property vhost_scsi_properties[] = { -DEFINE_VHOST_SCSI_PROPERTIES(VHostSCSI, parent_obj.conf), +DEFINE_PROP_STRING("vhostfd", VHostSCSI, parent_obj.conf.vhostfd), +DEFINE_PROP_STRING("wwpn", VHostSCSI, parent_obj.conf.wwpn), +DEFINE_PROP_UINT32("boot_tpgt", VHostSCSI, parent_obj.conf.boot_tpgt, 0), +DEFINE_PROP_UINT32("num_queues", VHostSCSI, parent_obj.conf.num_queues, 1), +DEFINE_PROP_UINT32("max_sectors", VHostSCSI, parent_obj.conf.max_sectors, + 0x), +DEFINE_PROP_UINT32("cmd_per_lun", VHostSCSI, parent_obj.conf.cmd_per_lun, + 128), DEFINE_PROP_END_OF_LIST(), }; -- MST
[Qemu-devel] [PULL 30/42] virtio-pci: fill VirtIOPCIRegions early.
From: Gerd Hoffmann Initialize the modern bar and the VirtIOPCIRegion fields early, in realize. Also add a size field to VirtIOPCIRegion and variables for pci bars to VirtIOPCIProxy. This allows virtio-pci subclasses to change things before the device_plugged callback applies them. virtio-vga will use that to arrange regions in a way that virtio-vga is compatible to both stdvga (in vga mode) and virtio-gpu-pci (in pci mode). Signed-off-by: Gerd Hoffmann Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.h | 4 +++ hw/virtio/virtio-pci.c | 92 -- 2 files changed, 55 insertions(+), 41 deletions(-) diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h index ea1343d..ff5ab71 100644 --- a/hw/virtio/virtio-pci.h +++ b/hw/virtio/virtio-pci.h @@ -94,6 +94,7 @@ typedef struct VirtioPCIClass { typedef struct VirtIOPCIRegion { MemoryRegion mr; uint32_t offset; +uint32_t size; uint32_t type; } VirtIOPCIRegion; @@ -105,6 +106,9 @@ struct VirtIOPCIProxy { VirtIOPCIRegion device; VirtIOPCIRegion notify; MemoryRegion modern_bar; +uint32_t legacy_io_bar; +uint32_t msix_bar; +uint32_t modern_mem_bar; uint32_t flags; uint32_t class_code; uint32_t nvectors; diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 771bbd5..76653a7 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1250,32 +1250,26 @@ static void virtio_pci_modern_regions_init(VirtIOPCIProxy *proxy) memory_region_init_io(&proxy->common.mr, OBJECT(proxy), &common_ops, proxy, - "virtio-pci-common", 0x1000); -proxy->common.offset = 0x0; -proxy->common.type = VIRTIO_PCI_CAP_COMMON_CFG; + "virtio-pci-common", + proxy->common.size); memory_region_init_io(&proxy->isr.mr, OBJECT(proxy), &isr_ops, proxy, - "virtio-pci-isr", 0x1000); -proxy->isr.offset = 0x1000; -proxy->isr.type = VIRTIO_PCI_CAP_ISR_CFG; + "virtio-pci-isr", + proxy->isr.size); memory_region_init_io(&proxy->device.mr, OBJECT(proxy), &device_ops, virtio_bus_get_device(&proxy->bus), - "virtio-pci-device", 0x1000); -proxy->device.offset = 0x2000; -proxy->device.type = VIRTIO_PCI_CAP_DEVICE_CFG; + "virtio-pci-device", + proxy->device.size); memory_region_init_io(&proxy->notify.mr, OBJECT(proxy), ¬ify_ops, virtio_bus_get_device(&proxy->bus), "virtio-pci-notify", - QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * - VIRTIO_QUEUE_MAX); -proxy->notify.offset = 0x3000; -proxy->notify.type = VIRTIO_PCI_CAP_NOTIFY_CFG; + proxy->notify.size); } static void virtio_pci_modern_region_map(VirtIOPCIProxy *proxy, @@ -1287,8 +1281,9 @@ static void virtio_pci_modern_region_map(VirtIOPCIProxy *proxy, ®ion->mr); cap->cfg_type = region->type; +cap->bar = proxy->modern_mem_bar; cap->offset = cpu_to_le32(region->offset); -cap->length = cpu_to_le32(memory_region_size(®ion->mr)); +cap->length = cpu_to_le32(region->size); virtio_pci_add_mem_cap(proxy, cap); } @@ -1303,22 +1298,6 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) uint32_t size; VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); -/* - * virtio pci bar layout - * - * region 0 -- virtio legacy io bar - * region 1 -- msi-x bar - * region 2+3 -- not used by virtio-pci - * region 4+5 -- virtio modern memory (64bit) bar - * - * Regions 2+3 can be used by VirtIOPCIProxy subclasses. - * virtio-vga places the vga framebuffer there. - * - */ -uint32_t legacy_io_bar = 0; -uint32_t msix_bar = 1; -uint32_t modern_mem_bar = 4; - config = proxy->pci_dev.config; if (proxy->class_code) { pci_config_set_class(config, proxy->class_code); @@ -1343,11 +1322,9 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) if (modern) { struct virtio_pci_cap cap = { .cap_len = sizeof cap, -.bar = modern_mem_bar, }; struct virtio_pci_notify_cap notify = { .cap.cap_len = sizeof notify, -.cap.bar = modern_mem_bar, .notify_off_multiplier = cpu_to_le32(QEMU_VIRTIO_PCI_QUEUE_MEM_MULT), }; @@ -1355,15 +1332,12 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) /*
[Qemu-devel] [PULL 32/42] virtio-input: core code & base class [pci]
From: Gerd Hoffmann This patch adds the virtio-pci support bits for virtio-input-device. Signed-off-by: Gerd Hoffmann Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.h | 14 ++ hw/virtio/virtio-pci.c | 36 2 files changed, 50 insertions(+) diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h index ff5ab71..754971f 100644 --- a/hw/virtio/virtio-pci.h +++ b/hw/virtio/virtio-pci.h @@ -24,6 +24,7 @@ #include "hw/virtio/virtio-balloon.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-9p.h" +#include "hw/virtio/virtio-input.h" #ifdef CONFIG_VIRTFS #include "hw/9pfs/virtio-9p.h" #endif @@ -39,6 +40,7 @@ typedef struct VirtIOSerialPCI VirtIOSerialPCI; typedef struct VirtIONetPCI VirtIONetPCI; typedef struct VHostSCSIPCI VHostSCSIPCI; typedef struct VirtIORngPCI VirtIORngPCI; +typedef struct VirtIOInputPCI VirtIOInputPCI; /* virtio-pci-bus */ @@ -234,6 +236,18 @@ struct VirtIORngPCI { VirtIORNG vdev; }; +/* + * virtio-input-pci: This extends VirtioPCIProxy. + */ +#define TYPE_VIRTIO_INPUT_PCI "virtio-input-pci" +#define VIRTIO_INPUT_PCI(obj) \ +OBJECT_CHECK(VirtIOInputPCI, (obj), TYPE_VIRTIO_INPUT_PCI) + +struct VirtIOInputPCI { +VirtIOPCIProxy parent_obj; +VirtIOInput vdev; +}; + /* Virtio ABI version, if we increment this, we break the guest driver. */ #define VIRTIO_PCI_ABI_VERSION 0 diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 76653a7..8ec741b 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -24,6 +24,7 @@ #include "hw/virtio/virtio-serial.h" #include "hw/virtio/virtio-scsi.h" #include "hw/virtio/virtio-balloon.h" +#include "hw/virtio/virtio-input.h" #include "hw/pci/pci.h" #include "qemu/error-report.h" #include "hw/pci/msi.h" @@ -1897,6 +1898,40 @@ static const TypeInfo virtio_rng_pci_info = { .class_init= virtio_rng_pci_class_init, }; +/* virtio-input-pci */ + +static void virtio_input_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) +{ +VirtIOInputPCI *vinput = VIRTIO_INPUT_PCI(vpci_dev); +DeviceState *vdev = DEVICE(&vinput->vdev); + +qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus)); +/* force virtio-1.0 */ +vpci_dev->flags &= ~VIRTIO_PCI_FLAG_DISABLE_MODERN; +vpci_dev->flags |= VIRTIO_PCI_FLAG_DISABLE_LEGACY; +object_property_set_bool(OBJECT(vdev), true, "realized", errp); +} + +static void virtio_input_pci_class_init(ObjectClass *klass, void *data) +{ +DeviceClass *dc = DEVICE_CLASS(klass); +VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass); +PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass); + +k->realize = virtio_input_pci_realize; +set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + +pcidev_k->class_id = PCI_CLASS_INPUT_OTHER; +} + +static const TypeInfo virtio_input_pci_info = { +.name = TYPE_VIRTIO_INPUT_PCI, +.parent= TYPE_VIRTIO_PCI, +.instance_size = sizeof(VirtIOInputPCI), +.class_init= virtio_input_pci_class_init, +.abstract = true, +}; + /* virtio-pci-bus */ static void virtio_pci_bus_new(VirtioBusState *bus, size_t bus_size, @@ -1938,6 +1973,7 @@ static const TypeInfo virtio_pci_bus_info = { static void virtio_pci_register_types(void) { type_register_static(&virtio_rng_pci_info); +type_register_static(&virtio_input_pci_info); type_register_static(&virtio_pci_bus_info); type_register_static(&virtio_pci_info); #ifdef CONFIG_VIRTFS -- MST
Re: [Qemu-devel] [PATCH v3 2/2] vhost user: Add RARP injection for legacy guest
I am not sure to understand your remark: > It needs to be sent when backend is activated by guest kick > (in case of virtio 1, it's possible to use DRIVER_OK for this). > This does not happen when VM still runs on source. Could you confirm rarp can be sent by backend when the VHOST_USER_SET_VRING_KICK message is received by the backend ? At this time the migration is completed and there is no risk of confusing the switch. In this case: - there are nothing to do in QEMU to manage legacy guest with no GUEST_ANNOUNCE. - All the job is done by the backend on the VHOST_USER_SET_VRING_KICK reception. Maybe switch notification of live migration is done with a small delay but it works - This patch can be discarded. On Thu, Jun 11, 2015 at 12:38 PM, Michael S. Tsirkin wrote: > On Thu, Jun 11, 2015 at 01:54:22PM +0800, Jason Wang wrote: > > > > > > On 06/11/2015 01:49 PM, Thibaut Collet wrote: > > > > Yes, but still need a mechanism to notify the backend of migration > > > > completion from qemu side if GUEST_ANNOUNCE is not negotiated. > > > > > > backend is aware of a connection with the guest (with the feature > > > negociation) and can send a rarp. This rarp will be always sent by the > > > backend when a VM is launched (first start or live migration > > > completion) if the GUEST_ANOUNCE is not supported. > > > In this case the issue is solved without done everything by QEMU. > > > > The issue is during migration guest network is still active. So sending > > rarp too early in the destination (e.g during VM is launched) may > > confuse the switch. We want it to be sent exactly when the migration is > > completed in destination. > > It needs to be sent when backend is activated by guest kick > (in case of virtio 1, it's possible to use DRIVER_OK for this). > This does not happen when VM still runs on source. > > > > If sending a rarp message on the start of te VM is not accceptable, we > > > must provide a mechanism similar of the one I have implemented. The > > > message content can be empty as the backend is able to create the rarp > > > message. > > > > Yes. >
[Qemu-devel] [PULL 34/42] virtio-net: move qdev properties into virtio-net.c
From: Shannon Zhao As only one place in virtio-net.c uses DEFINE_VIRTIO_NET_FEATURES, there is no need to expose it. Inline it into virtio-net.c to avoid wrongly use. Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao Reviewed-by: Paolo Bonzini Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-net.h | 24 --- hw/net/virtio-net.c| 44 -- 2 files changed, 42 insertions(+), 26 deletions(-) diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index e0dbb41..c142b42 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -109,30 +109,6 @@ typedef struct VirtIONet { #define VIRTIO_NET_CTRL_GUEST_OFFLOADS 5 #define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET0 -#define DEFINE_VIRTIO_NET_FEATURES(_state, _field) \ -DEFINE_PROP_BIT("any_layout", _state, _field, VIRTIO_F_ANY_LAYOUT, true), \ -DEFINE_PROP_BIT("csum", _state, _field, VIRTIO_NET_F_CSUM, true), \ -DEFINE_PROP_BIT("guest_csum", _state, _field, VIRTIO_NET_F_GUEST_CSUM, true), \ -DEFINE_PROP_BIT("gso", _state, _field, VIRTIO_NET_F_GSO, true), \ -DEFINE_PROP_BIT("guest_tso4", _state, _field, VIRTIO_NET_F_GUEST_TSO4, true), \ -DEFINE_PROP_BIT("guest_tso6", _state, _field, VIRTIO_NET_F_GUEST_TSO6, true), \ -DEFINE_PROP_BIT("guest_ecn", _state, _field, VIRTIO_NET_F_GUEST_ECN, true), \ -DEFINE_PROP_BIT("guest_ufo", _state, _field, VIRTIO_NET_F_GUEST_UFO, true), \ -DEFINE_PROP_BIT("guest_announce", _state, _field, VIRTIO_NET_F_GUEST_ANNOUNCE, true), \ -DEFINE_PROP_BIT("host_tso4", _state, _field, VIRTIO_NET_F_HOST_TSO4, true), \ -DEFINE_PROP_BIT("host_tso6", _state, _field, VIRTIO_NET_F_HOST_TSO6, true), \ -DEFINE_PROP_BIT("host_ecn", _state, _field, VIRTIO_NET_F_HOST_ECN, true), \ -DEFINE_PROP_BIT("host_ufo", _state, _field, VIRTIO_NET_F_HOST_UFO, true), \ -DEFINE_PROP_BIT("mrg_rxbuf", _state, _field, VIRTIO_NET_F_MRG_RXBUF, true), \ -DEFINE_PROP_BIT("status", _state, _field, VIRTIO_NET_F_STATUS, true), \ -DEFINE_PROP_BIT("ctrl_vq", _state, _field, VIRTIO_NET_F_CTRL_VQ, true), \ -DEFINE_PROP_BIT("ctrl_rx", _state, _field, VIRTIO_NET_F_CTRL_RX, true), \ -DEFINE_PROP_BIT("ctrl_vlan", _state, _field, VIRTIO_NET_F_CTRL_VLAN, true), \ -DEFINE_PROP_BIT("ctrl_rx_extra", _state, _field, VIRTIO_NET_F_CTRL_RX_EXTRA, true), \ -DEFINE_PROP_BIT("ctrl_mac_addr", _state, _field, VIRTIO_NET_F_CTRL_MAC_ADDR, true), \ -DEFINE_PROP_BIT("ctrl_guest_offloads", _state, _field, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS, true), \ -DEFINE_PROP_BIT("mq", _state, _field, VIRTIO_NET_F_MQ, false) - #define DEFINE_VIRTIO_NET_PROPERTIES(_state, _field) \ DEFINE_PROP_UINT32("x-txtimer", _state, _field.txtimer, TX_TIMER_INTERVAL),\ DEFINE_PROP_INT32("x-txburst", _state, _field.txburst, TX_BURST), \ diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 49fa13f..9281aa1 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1707,10 +1707,50 @@ static void virtio_net_instance_init(Object *obj) } static Property virtio_net_properties[] = { -DEFINE_VIRTIO_NET_FEATURES(VirtIONet, host_features), +DEFINE_PROP_BIT("any_layout", VirtIONet, host_features, +VIRTIO_F_ANY_LAYOUT, true), +DEFINE_PROP_BIT("csum", VirtIONet, host_features, VIRTIO_NET_F_CSUM, true), +DEFINE_PROP_BIT("guest_csum", VirtIONet, host_features, +VIRTIO_NET_F_GUEST_CSUM, true), +DEFINE_PROP_BIT("gso", VirtIONet, host_features, VIRTIO_NET_F_GSO, true), +DEFINE_PROP_BIT("guest_tso4", VirtIONet, host_features, +VIRTIO_NET_F_GUEST_TSO4, true), +DEFINE_PROP_BIT("guest_tso6", VirtIONet, host_features, +VIRTIO_NET_F_GUEST_TSO6, true), +DEFINE_PROP_BIT("guest_ecn", VirtIONet, host_features, +VIRTIO_NET_F_GUEST_ECN, true), +DEFINE_PROP_BIT("guest_ufo", VirtIONet, host_features, +VIRTIO_NET_F_GUEST_UFO, true), +DEFINE_PROP_BIT("guest_announce", VirtIONet, host_features, +VIRTIO_NET_F_GUEST_ANNOUNCE, true), +DEFINE_PROP_BIT("host_tso4", VirtIONet, host_features, +VIRTIO_NET_F_HOST_TSO4, true), +DEFINE_PROP_BIT("host_tso6", VirtIONet, host_features, +VIRTIO_NET_F_HOST_TSO6, true), +DEFINE_PROP_BIT("host_ecn", VirtIONet, host_features, +VIRTIO_NET_F_HOST_ECN, true), +DEFINE_PROP_BIT("host_ufo", VirtIONet, host_features, +VIRTIO_NET_F_HOST_UFO, true), +DEFINE_PROP_BIT("mrg_rxbuf", VirtIONet, host_features, +VIRTIO_NET_F_MRG_RXBUF, true), +DEFINE_PROP_BIT("status", VirtIONet, host_features, +VIRTI
[Qemu-devel] [PULL 38/42] virtio-serial-bus: move qdev properties into virtio-serial-bus.c
From: Shannon Zhao As only one place in virtio-serial-bus.c uses DEFINE_VIRTIO_SERIAL_PROPERTIES, there is no need to expose it. Inline it into virtio-serial-bus.c to avoid wrongly use. Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao Reviewed-by: Paolo Bonzini Acked-by: Cornelia Huck Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-serial.h | 3 --- hw/char/virtio-serial-bus.c | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/include/hw/virtio/virtio-serial.h b/include/hw/virtio/virtio-serial.h index 18d1bcc..527d0bf 100644 --- a/include/hw/virtio/virtio-serial.h +++ b/include/hw/virtio/virtio-serial.h @@ -221,7 +221,4 @@ void virtio_serial_throttle_port(VirtIOSerialPort *port, bool throttle); #define VIRTIO_SERIAL(obj) \ OBJECT_CHECK(VirtIOSerial, (obj), TYPE_VIRTIO_SERIAL) -#define DEFINE_VIRTIO_SERIAL_PROPERTIES(_state, _field) \ -DEFINE_PROP_UINT32("max_ports", _state, _field.max_virtserial_ports, 31) - #endif diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index f893523..d451b22 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -1083,7 +1083,8 @@ static void virtio_serial_device_unrealize(DeviceState *dev, Error **errp) } static Property virtio_serial_properties[] = { -DEFINE_VIRTIO_SERIAL_PROPERTIES(VirtIOSerial, serial), +DEFINE_PROP_UINT32("max_ports", VirtIOSerial, serial.max_virtserial_ports, + 31), DEFINE_PROP_END_OF_LIST(), }; -- MST
[Qemu-devel] [PULL 21/42] virtio-pci: correctly set host notifiers for modern bar
From: Jason Wang Currently, during host notifier set. We only add eventfd for legacy bar, this is not correct since: - Non-transitional device does not have legacy bar, so qemu will crash since proxy->bar was not initialized. - Modern device uses modern bar and notify cap to notify the device, we should add eventfd for proxy->notify. So this patch fixes the above two issues by adding eventfd based on whether legacy or modern device were supported. Signed-off-by: Jason Wang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.c | 31 +-- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 7804361..b7beddd 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -135,12 +135,21 @@ static int virtio_pci_load_queue(DeviceState *d, int n, QEMUFile *f) return 0; } +#define QEMU_VIRTIO_PCI_QUEUE_MEM_MULT 0x1000 + static int virtio_pci_set_host_notifier_internal(VirtIOPCIProxy *proxy, int n, bool assign, bool set_handler) { VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); VirtQueue *vq = virtio_get_queue(vdev, n); EventNotifier *notifier = virtio_queue_get_host_notifier(vq); +bool legacy = !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_LEGACY); +bool modern = !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN); +MemoryRegion *modern_mr = &proxy->notify; +MemoryRegion *legacy_mr = &proxy->bar; +hwaddr modern_addr = QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * + virtio_get_queue_index(vq); +hwaddr legacy_addr = VIRTIO_PCI_QUEUE_NOTIFY; int r = 0; if (assign) { @@ -151,11 +160,23 @@ static int virtio_pci_set_host_notifier_internal(VirtIOPCIProxy *proxy, return r; } virtio_queue_set_host_notifier_fd_handler(vq, true, set_handler); -memory_region_add_eventfd(&proxy->bar, VIRTIO_PCI_QUEUE_NOTIFY, 2, - true, n, notifier); +if (modern) { +memory_region_add_eventfd(modern_mr, modern_addr, 2, + true, n, notifier); +} +if (legacy) { +memory_region_add_eventfd(legacy_mr, legacy_addr, 2, + true, n, notifier); +} } else { -memory_region_del_eventfd(&proxy->bar, VIRTIO_PCI_QUEUE_NOTIFY, 2, - true, n, notifier); +if (modern) { +memory_region_del_eventfd(modern_mr, modern_addr, 2, + true, n, notifier); +} +if (legacy) { +memory_region_del_eventfd(legacy_mr, legacy_addr, 2, + true, n, notifier); +} virtio_queue_set_host_notifier_fd_handler(vq, false, false); event_notifier_cleanup(notifier); } @@ -934,8 +955,6 @@ static void virtio_pci_add_mem_cap(VirtIOPCIProxy *proxy, cap->cap_len - PCI_CAP_FLAGS); } -#define QEMU_VIRTIO_PCI_QUEUE_MEM_MULT 0x1000 - static uint64_t virtio_pci_common_read(void *opaque, hwaddr addr, unsigned size) { -- MST
[Qemu-devel] [PULL 00/42] pc, acpi, virtio
The following changes since commit 309750fad51f17d1ec6195c5d8ad7d741596ddb6: vhost: logs sharing (2015-06-04 12:44:49 +0200) are available in the git repository at: git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream for you to fetch changes up to 4ebc736e9938a7e88ecc785734b17145bf802a56: i386/acpi-build: fix PXB workarounds for unsupported BIOSes (2015-06-11 12:40:30 +0200) pc, acpi, virtio Most notably this includes virtio 1 patches Still not all devices converted, and not fully spec compliant, so disabled by default. Signed-off-by: Michael S. Tsirkin Cornelia Huck (10): virtio: endianness checks for virtio 1.0 devices virtio: allow virtio-1 queue layout dataplane: allow virtio-1 devices virtio: disallow late feature changes for virtio-1 virtio: allow to fail setting status virtio-net: no writeable mac for virtio-1 virtio-net: support longer header virtio-net: enable virtio 1.0 vhost: 64 bit features virtio-balloon: switch to virtio_add_feature Gerd Hoffmann (14): virtio-pci: add flags to enable/disable legacy/modern virtio-pci: make QEMU_VIRTIO_PCI_QUEUE_MEM_MULT smaller virtio-pci: change & document virtio pci bar layout. virtio-pci: make modern bar 64bit + prefetchable virtio-pci: add struct VirtIOPCIRegion for virtio-1 regions virtio-pci: add virtio_pci_modern_regions_init() virtio-pci: add virtio_pci_modern_region_map() virtio-pci: move virtio_pci_add_mem_cap call to virtio_pci_modern_region_map virtio-pci: move cap type to VirtIOPCIRegion virtio-pci: drop identical virtio_pci_cap virtio-pci: fill VirtIOPCIRegions early. pci: add PCI_CLASS_INPUT_* virtio-input: core code & base class [pci] virtio-input: emulated devices [pci] Jason Wang (2): vhost: put log correctly in vhost_dev_start() virtio-pci: correctly set host notifiers for modern bar Laszlo Ersek (2): i386/acpi-build: more traditional _UID and _HID for PXB root buses i386/acpi-build: fix PXB workarounds for unsupported BIOSes Michael S. Tsirkin (7): vhost_net: add version_1 feature linux-headers: add virtio_pci virtio-pci: initial virtio 1.0 support virtio: generation counter support virtio: add modern config accessors virtio-pci: switch to modern accessors for 1.0 virtio_balloon: header update Shannon Zhao (7): virtio-net: move qdev properties into virtio-net.c virtio-net.h: Remove unsed DEFINE_VIRTIO_NET_PROPERTIES virtio-scsi: move qdev properties into virtio-scsi.c virtio-rng: move qdev properties into virtio-rng.c virtio-serial-bus: move qdev properties into virtio-serial-bus.c virtio-9p-device: move qdev properties into virtio-9p-device.c vhost-scsi: move qdev properties into vhost-scsi.c hw/9pfs/virtio-9p.h| 4 - hw/virtio/virtio-pci.h | 59 include/hw/pci/pci_ids.h | 7 + include/hw/virtio/vhost-scsi.h | 9 - include/hw/virtio/vhost.h | 6 +- include/hw/virtio/virtio-access.h | 4 + include/hw/virtio/virtio-balloon.h | 6 + include/hw/virtio/virtio-net.h | 31 +- include/hw/virtio/virtio-rng.h | 10 - include/hw/virtio/virtio-scsi.h| 13 - include/hw/virtio/virtio-serial.h | 3 - include/hw/virtio/virtio.h | 24 +- include/net/vhost_net.h| 4 +- linux-headers/linux/virtio_pci.h | 192 hw/9pfs/virtio-9p-device.c | 3 +- hw/char/virtio-serial-bus.c| 3 +- hw/i386/acpi-build.c | 13 +- hw/net/vhost_net.c | 14 +- hw/net/virtio-net.c| 67 +++- hw/s390x/virtio-ccw.c | 20 +- hw/scsi/vhost-scsi.c | 9 +- hw/scsi/virtio-scsi.c | 13 +- hw/virtio/dataplane/vring.c| 47 +-- hw/virtio/vhost.c | 18 +- hw/virtio/virtio-balloon.c | 2 +- hw/virtio/virtio-mmio.c| 3 + hw/virtio/virtio-pci.c | 612 +++-- hw/virtio/virtio-rng.c | 8 +- hw/virtio/virtio.c | 198 ++-- 29 files changed, 1214 insertions(+), 188 deletions(-) create mode 100644 linux-headers/linux/virtio_pci.h
Re: [Qemu-devel] [PATCH v3 2/2] vhost user: Add RARP injection for legacy guest
On Thu, Jun 11, 2015 at 02:10:48PM +0200, Thibaut Collet wrote: > I am not sure to understand your remark: > > > It needs to be sent when backend is activated by guest kick > > (in case of virtio 1, it's possible to use DRIVER_OK for this). > > This does not happen when VM still runs on source. > > Could you confirm rarp can be sent by backend when the > VHOST_USER_SET_VRING_KICK message is received by the backend ? No - the time to send pakets is when you start processing the rings. And the time to do that is when you detect a kick on an eventfd, not when said fd is set. > At this time the migration is completed and there is no risk of confusing the > switch. > In this case: > - there are nothing to do in QEMU to manage legacy guest with > no GUEST_ANNOUNCE. > - All the job is done by the backend on the VHOST_USER_SET_VRING_KICK > reception. Maybe switch notification of live migration is done with a small > delay but it works > - This patch can be discarded. > > > On Thu, Jun 11, 2015 at 12:38 PM, Michael S. Tsirkin wrote: > > On Thu, Jun 11, 2015 at 01:54:22PM +0800, Jason Wang wrote: > > > > > > On 06/11/2015 01:49 PM, Thibaut Collet wrote: > > > > Yes, but still need a mechanism to notify the backend of migration > > > > completion from qemu side if GUEST_ANNOUNCE is not negotiated. > > > > > > backend is aware of a connection with the guest (with the feature > > > negociation) and can send a rarp. This rarp will be always sent by the > > > backend when a VM is launched (first start or live migration > > > completion) if the GUEST_ANOUNCE is not supported. > > > In this case the issue is solved without done everything by QEMU. > > > > The issue is during migration guest network is still active. So sending > > rarp too early in the destination (e.g during VM is launched) may > > confuse the switch. We want it to be sent exactly when the migration is > > completed in destination. > > It needs to be sent when backend is activated by guest kick > (in case of virtio 1, it's possible to use DRIVER_OK for this). > This does not happen when VM still runs on source. > > > > If sending a rarp message on the start of te VM is not accceptable, we > > > must provide a mechanism similar of the one I have implemented. The > > > message content can be empty as the backend is able to create the rarp > > > message. > > > > Yes. > >
[Qemu-devel] [PULL 37/42] virtio-rng: move qdev properties into virtio-rng.c
From: Shannon Zhao As only one place in virtio-rng.c uses DEFINE_VIRTIO_RNG_PROPERTIES, there is no need to expose it. Inline it into virtio-rng.c to avoid wrongly use. Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao Reviewed-by: Paolo Bonzini Acked-by: Cornelia Huck Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-rng.h | 10 -- hw/virtio/virtio-rng.c | 8 +++- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/include/hw/virtio/virtio-rng.h b/include/hw/virtio/virtio-rng.h index 7702ff4..0316488 100644 --- a/include/hw/virtio/virtio-rng.h +++ b/include/hw/virtio/virtio-rng.h @@ -46,14 +46,4 @@ typedef struct VirtIORNG { int64_t quota_remaining; } VirtIORNG; -/* Set a default rate limit of 2^47 bytes per minute or roughly 2TB/s. If - you have an entropy source capable of generating more entropy than this - and you can pass it through via virtio-rng, then hats off to you. Until - then, this is unlimited for all practical purposes. -*/ -#define DEFINE_VIRTIO_RNG_PROPERTIES(_state, _conf_field)\ -DEFINE_PROP_UINT64("max-bytes", _state, _conf_field.max_bytes, \ - INT64_MAX), \ -DEFINE_PROP_UINT32("period", _state, _conf_field.period_ms, 1 << 16) - #endif diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c index 420c39f..22b1d87 100644 --- a/hw/virtio/virtio-rng.c +++ b/hw/virtio/virtio-rng.c @@ -219,7 +219,13 @@ static void virtio_rng_device_unrealize(DeviceState *dev, Error **errp) } static Property virtio_rng_properties[] = { -DEFINE_VIRTIO_RNG_PROPERTIES(VirtIORNG, conf), +/* Set a default rate limit of 2^47 bytes per minute or roughly 2TB/s. If + * you have an entropy source capable of generating more entropy than this + * and you can pass it through via virtio-rng, then hats off to you. Until + * then, this is unlimited for all practical purposes. + */ +DEFINE_PROP_UINT64("max-bytes", VirtIORNG, conf.max_bytes, INT64_MAX), +DEFINE_PROP_UINT32("period", VirtIORNG, conf.period_ms, 1 << 16), DEFINE_PROP_END_OF_LIST(), }; -- MST
[Qemu-devel] [PULL 39/42] virtio-9p-device: move qdev properties into virtio-9p-device.c
From: Shannon Zhao As only one place in virtio-9p-device.c uses DEFINE_VIRTIO_9P_PROPERTIES, there is no need to expose it. Inline it into virtio-9p-device.c to avoid wrongly use. Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao Reviewed-by: Paolo Bonzini Acked-by: Cornelia Huck Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/9pfs/virtio-9p.h| 4 hw/9pfs/virtio-9p-device.c | 3 ++- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h index 58dafa9..2e7d488 100644 --- a/hw/9pfs/virtio-9p.h +++ b/hw/9pfs/virtio-9p.h @@ -391,8 +391,4 @@ extern int v9fs_name_to_path(V9fsState *s, V9fsPath *dirpath, #define VIRTIO_9P(obj) \ OBJECT_CHECK(V9fsState, (obj), TYPE_VIRTIO_9P) -#define DEFINE_VIRTIO_9P_PROPERTIES(_state, _field) \ -DEFINE_PROP_STRING("mount_tag", _state, _field.tag),\ -DEFINE_PROP_STRING("fsdev", _state, _field.fsdev_id) - #endif diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c index 60f9ff9..3f4c9e7 100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@ -140,7 +140,8 @@ out: /* virtio-9p device */ static Property virtio_9p_properties[] = { -DEFINE_VIRTIO_9P_PROPERTIES(V9fsState, fsconf), +DEFINE_PROP_STRING("mount_tag", V9fsState, fsconf.tag), +DEFINE_PROP_STRING("fsdev", V9fsState, fsconf.fsdev_id), DEFINE_PROP_END_OF_LIST(), }; -- MST
[Qemu-devel] [PULL 01/42] vhost: put log correctly in vhost_dev_start()
From: Jason Wang We allocate an dummy log even if the size is zero. So we should put it unconditionally too. Signed-off-by: Jason Wang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 01f1e04..3a52a4d 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -,9 +,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev) return 0; fail_log: -if (hdev->log_size) { -vhost_log_put(hdev, false); -} +vhost_log_put(hdev, false); fail_vq: while (--i >= 0) { vhost_virtqueue_stop(hdev, -- MST
[Qemu-devel] [PULL 42/42] i386/acpi-build: fix PXB workarounds for unsupported BIOSes
From: Laszlo Ersek The patch apci: fix PXB behaviour if used with unsupported BIOS uses the following condition to see if a "PXB mem/IO chunk" has *not* been configured by the BIOS: (!range_base || range_base > range_limit) When this condition evaluates to true, said patch *omits* the corresponding entry from the _CRS. Later on the patch checks for the opposite condition (with the intent of *adding* entries to the _CRS if the "PXB mem/IO chunks" *have* been configured). Unfortunately, the condition was negated incorrectly: only the first ! operator was removed, which led to the nonsensical expression (range_base || range_base > range_limit) leading to bogus entries in the _CRS, and causing BSOD in Windows Server 2012 R2 when it runs on OVMF. The correct negative of the condition seen at the top is (range_base && range_base <= range_limit) Fix the expressions. Cc: Marcel Apfelbaum Cc: Michael S. Tsirkin Signed-off-by: Laszlo Ersek Reviewed-by: Marcel Apfelbaum Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/acpi-build.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 8fae3b9..8e88ade 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -832,7 +832,7 @@ static Aml *build_crs(PCIHostState *host, * Work-around for old bioses * that do not support multiple root buses */ -if (range_base || range_base > range_limit) { +if (range_base && range_base <= range_limit) { aml_append(crs, aml_word_io(AML_MIN_FIXED, AML_MAX_FIXED, AML_POS_DECODE, AML_ENTIRE_RANGE, @@ -853,7 +853,7 @@ static Aml *build_crs(PCIHostState *host, * Work-around for old bioses * that do not support multiple root buses */ -if (range_base || range_base > range_limit) { +if (range_base && range_base <= range_limit) { aml_append(crs, aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED, AML_NON_CACHEABLE, @@ -864,7 +864,7 @@ static Aml *build_crs(PCIHostState *host, 0, range_limit - range_base + 1)); crs_range_insert(mem_ranges, range_base, range_limit); - } +} range_base = pci_bridge_get_base(dev, PCI_BASE_ADDRESS_MEM_PREFETCH); @@ -875,7 +875,7 @@ static Aml *build_crs(PCIHostState *host, * Work-around for old bioses * that do not support multiple root buses */ -if (range_base || range_base > range_limit) { +if (range_base && range_base <= range_limit) { aml_append(crs, aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED, AML_NON_CACHEABLE, -- MST