packages: qemu-kvm/0001-malta-Fix-regression-i8259-interrupts-did-not-work....

baggins baggins at pld-linux.org
Wed Feb 15 22:39:56 CET 2012


Author: baggins                      Date: Wed Feb 15 21:39:56 2012 GMT
Module: packages                      Tag: HEAD
---- Log message:
- patches queued for 1.0.1 stable

---- Files affected:
packages/qemu-kvm:
   0001-malta-Fix-regression-i8259-interrupts-did-not-work.patch (NONE -> 1.1)  (NEW), 0002-exec.c-Fix-subpage-memory-access-to-RAM-MemoryRegion.patch (NONE -> 1.1)  (NEW), 0003-hw-9pfs-Improve-portability-to-older-systems.patch (NONE -> 1.1)  (NEW), 0004-hw-9pfs-use-migration-blockers-to-prevent-live-migra.patch (NONE -> 1.1)  (NEW), 0005-hw-9pfs-Reset-server-state-during-TVERSION.patch (NONE -> 1.1)  (NEW), 0006-hw-9pfs-Add-qdev.reset-callback-for-virtio-9p-pci-de.patch (NONE -> 1.1)  (NEW), 0007-hw-9pfs-Use-the-correct-file-descriptor-in-Fsdriver-.patch (NONE -> 1.1)  (NEW), 0008-hw-9pfs-replace-iovec-manipulation-with-QEMUIOVector.patch (NONE -> 1.1)  (NEW), 0009-hw-9pfs-Use-the-correct-signed-type-for-different-va.patch (NONE -> 1.1)  (NEW), 0010-target-i386-fix-cmpxchg-instruction-emulation.patch (NONE -> 1.1)  (NEW), 0011-configure-Enable-build-by-default-PIE-read-only-relo.patch (NONE -> 1.1)  (NEW), 0012-cris-Handle-conditional-stores-on-CRISv10.patch (NONE -> 1.1)  (NEW), 0013-pc-add-pc-0.15.patch (NONE -> 1.1)  (NEW), 0014-pc-fix-event_idx-compatibility-for-virtio-devices.patch (NONE -> 1.1)  (NEW), 0015-Fix-parse-of-usb-device-description-with-multiple-co.patch (NONE -> 1.1)  (NEW), 0016-usb-storage-cancel-I-O-on-reset.patch (NONE -> 1.1)  (NEW), 0017-usb-host-properly-release-port-on-unplug-exit.patch (NONE -> 1.1)  (NEW), 0018-usb-ohci-td.cbp-incorrectly-updated-near-page-end.patch (NONE -> 1.1)  (NEW), 0019-target-sh4-ignore-ocbp-and-ocbwb-instructions.patch (NONE -> 1.1)  (NEW), 0020-PPC-Fix-linker-scripts-on-ppc-hosts.patch (NONE -> 1.1)  (NEW), 0021-qiov-prevent-double-free-or-use-after-free.patch (NONE -> 1.1)  (NEW), 0022-coroutine-switch-per-thread-free-pool-to-a-global-po.patch (NONE -> 1.1)  (NEW), 0023-qemu-img-rebase-Fix-for-undersized-backing-files.patch (NONE -> 1.1)  (NEW), 0024-Documentation-Add-qemu-img-t-parameter-in-man-page.patch (NONE -> 1.1)  (NEW), 0025-rbd-always-set-out-parameter-in-qemu_rbd_snap_list.patch (NONE -> 1.1)  (NEW), 0026-e1000-bounds-packet-size-against-buffer-size.patch (NONE -> 1.1)  (NEW), virtio-blk_refuse_SG_IO_requests_with_scsi_off.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: packages/qemu-kvm/0001-malta-Fix-regression-i8259-interrupts-did-not-work.patch
diff -u /dev/null packages/qemu-kvm/0001-malta-Fix-regression-i8259-interrupts-did-not-work.patch:1.1
--- /dev/null	Wed Feb 15 22:39:56 2012
+++ packages/qemu-kvm/0001-malta-Fix-regression-i8259-interrupts-did-not-work.patch	Wed Feb 15 22:39:50 2012
@@ -0,0 +1,132 @@
+From 0b23c5d40ea933cfece3b4f69427f79c8a23256d Mon Sep 17 00:00:00 2001
+From: Stefan Weil <sw at weilnetz.de>
+Date: Tue, 29 Nov 2011 06:34:48 +0100
+Subject: [PATCH 01/25] malta: Fix regression (i8259 interrupts did not work)
+
+Commit 5632ae46d5bda798e971dae48ebb318ac2c3686a passes the address
+of i8259 to qemu_irq_proxy. i8259 is an auto variable with undefined
+value outside of mips_malta_init.
+
+This made the interrupt proxy unusable: either QEMU crashes, or
+the interrupt handler was not called.
+
+Ethernet for example no longer worked with MIPS Malta.
+
+v2:
+While v1 used a static variable for i8259, this patch introduces
+a qdev for the malta machine. i8259 is now part of the device status.
+This is a minimal qdev implementation to keep the patch small.
+
+Signed-off-by: Stefan Weil <sw at weilnetz.de>
+Signed-off-by: Aurelien Jarno <aurelien at aurel32.net>
+(cherry picked from commit e9b40fd34ceb23461083d505a444a389c094455b)
+---
+ hw/mips_malta.c |   39 +++++++++++++++++++++++++++++++++++----
+ 1 files changed, 35 insertions(+), 4 deletions(-)
+
+diff --git a/hw/mips_malta.c b/hw/mips_malta.c
+index bb49749..941b9bd 100644
+--- a/hw/mips_malta.c
++++ b/hw/mips_malta.c
+@@ -47,6 +47,7 @@
+ #include "mc146818rtc.h"
+ #include "blockdev.h"
+ #include "exec-memory.h"
++#include "sysbus.h"             /* SysBusDevice */
+
+ //#define DEBUG_BOARD_INIT
+
+@@ -72,6 +73,11 @@ typedef struct {
+     SerialState *uart;
+ } MaltaFPGAState;
+
++typedef struct {
++    SysBusDevice busdev;
++    qemu_irq *i8259;
++} MaltaState;
++
+ static ISADevice *pit;
+
+ static struct _loaderparams {
+@@ -775,7 +781,7 @@ void mips_malta_init (ram_addr_t ram_size,
+     int64_t kernel_entry;
+     PCIBus *pci_bus;
+     CPUState *env;
+-    qemu_irq *i8259 = NULL, *isa_irq;
++    qemu_irq *isa_irq;
+     qemu_irq *cpu_exit_irq;
+     int piix4_devfn;
+     i2c_bus *smbus;
+@@ -787,6 +793,11 @@ void mips_malta_init (ram_addr_t ram_size,
+     int fl_sectors = 0;
+     int be;
+
++    DeviceState *dev = qdev_create(NULL, "mips-malta");
++    MaltaState *s = DO_UPCAST(MaltaState, busdev.qdev, dev);
++
++    qdev_init_nofail(dev);
++
+     /* Make sure the first 3 serial ports are associated with a device. */
+     for(i = 0; i < 3; i++) {
+         if (!serial_hds[i]) {
+@@ -932,7 +943,7 @@ void mips_malta_init (ram_addr_t ram_size,
+      * qemu_irq_proxy() adds an extra bit of indirection, allowing us
+      * to resolve the isa_irq -> i8259 dependency after i8259 is initialized.
+      */
+-    isa_irq = qemu_irq_proxy(&i8259, 16);
++    isa_irq = qemu_irq_proxy(&s->i8259, 16);
+
+     /* Northbridge */
+     pci_bus = gt64120_register(isa_irq);
+@@ -944,9 +955,9 @@ void mips_malta_init (ram_addr_t ram_size,
+
+     /* Interrupt controller */
+     /* The 8259 is attached to the MIPS CPU INT0 pin, ie interrupt 2 */
+-    i8259 = i8259_init(env->irq[2]);
++    s->i8259 = i8259_init(env->irq[2]);
+
+-    isa_bus_irqs(i8259);
++    isa_bus_irqs(s->i8259);
+     pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1);
+     usb_uhci_piix4_init(pci_bus, piix4_devfn + 2);
+     smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100, isa_get_irq(9),
+@@ -990,6 +1001,20 @@ void mips_malta_init (ram_addr_t ram_size,
+     }
+ }
+
++static int mips_malta_sysbus_device_init(SysBusDevice *sysbusdev)
++{
++    return 0;
++}
++
++static SysBusDeviceInfo mips_malta_device = {
++    .init = mips_malta_sysbus_device_init,
++    .qdev.name  = "mips-malta",
++    .qdev.size  = sizeof(MaltaState),
++    .qdev.props = (Property[]) {
++        DEFINE_PROP_END_OF_LIST(),
++    }
++};
++
+ static QEMUMachine mips_malta_machine = {
+     .name = "malta",
+     .desc = "MIPS Malta Core LV",
+@@ -998,9 +1023,15 @@ static QEMUMachine mips_malta_machine = {
+     .is_default = 1,
+ };
+
++static void mips_malta_device_init(void)
++{
++    sysbus_register_withprop(&mips_malta_device);
++}
++
+ static void mips_malta_machine_init(void)
+ {
+     qemu_register_machine(&mips_malta_machine);
+ }
+
++device_init(mips_malta_device_init);
+ machine_init(mips_malta_machine_init);
+-- 
+1.7.7.5
+

================================================================
Index: packages/qemu-kvm/0002-exec.c-Fix-subpage-memory-access-to-RAM-MemoryRegion.patch
diff -u /dev/null packages/qemu-kvm/0002-exec.c-Fix-subpage-memory-access-to-RAM-MemoryRegion.patch:1.1
--- /dev/null	Wed Feb 15 22:39:56 2012
+++ packages/qemu-kvm/0002-exec.c-Fix-subpage-memory-access-to-RAM-MemoryRegion.patch	Wed Feb 15 22:39:50 2012
@@ -0,0 +1,134 @@
+From 2061800b85ddcc9b34b5ccbfaa87f7e8b94626a6 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Andreas=20F=C3=A4rber?= <afaerber at suse.de>
+Date: Wed, 30 Nov 2011 16:26:21 +0100
+Subject: [PATCH 02/25] exec.c: Fix subpage memory access to RAM MemoryRegion
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Commit 95c318f5e1f88d7e5bcc6deac17330fd4806a2d3 (Fix segfault in mmio
+subpage handling code.) prevented a segfault by making all subpage
+registrations over an existing memory page perform an unassigned access.
+Symptoms were writes not taking effect and reads returning zero.
+
+Very small page sizes are not currently supported either,
+so subpage memory areas cannot fully be avoided.
+
+Therefore change the previous fix to use a new IO_MEM_SUBPAGE_RAM
+instead of IO_MEM_UNASSIGNED. Suggested by Avi.
+
+Reviewed-by: Avi Kivity <avi at redhat.com>
+Signed-off-by: Andreas Färber <afaerber at suse.de>
+Cc: Avi Kivity <avi at redhat.com>
+Cc: Gleb Natapov <gleb at redhat.com>
+Signed-off-by: Anthony Liguori <aliguori at us.ibm.com>
+---
+ cpu-common.h |    1 +
+ exec.c       |   65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
+ 2 files changed, 64 insertions(+), 2 deletions(-)
+
+diff --git a/cpu-common.h b/cpu-common.h
+index c9878ba..3f45428 100644
+--- a/cpu-common.h
++++ b/cpu-common.h
+@@ -172,6 +172,7 @@ void cpu_physical_memory_write_rom(target_phys_addr_t addr,
+ #define IO_MEM_ROM         (1 << IO_MEM_SHIFT) /* hardcoded offset */
+ #define IO_MEM_UNASSIGNED  (2 << IO_MEM_SHIFT)
+ #define IO_MEM_NOTDIRTY    (3 << IO_MEM_SHIFT)
++#define IO_MEM_SUBPAGE_RAM (4 << IO_MEM_SHIFT)
+
+ /* Acts like a ROM when read and like a device when written.  */
+ #define IO_MEM_ROMD        (1)
+diff --git a/exec.c b/exec.c
+index 6b92198..6c206ff 100644
+--- a/exec.c
++++ b/exec.c
+@@ -3570,6 +3570,63 @@ static CPUWriteMemoryFunc * const subpage_write[] = {
+     &subpage_writel,
+ };
+
++static uint32_t subpage_ram_readb(void *opaque, target_phys_addr_t addr)
++{
++    ram_addr_t raddr = addr;
++    void *ptr = qemu_get_ram_ptr(raddr);
++    return ldub_p(ptr);
++}
++
++static void subpage_ram_writeb(void *opaque, target_phys_addr_t addr,
++                               uint32_t value)
++{
++    ram_addr_t raddr = addr;
++    void *ptr = qemu_get_ram_ptr(raddr);
++    stb_p(ptr, value);
++}
++
++static uint32_t subpage_ram_readw(void *opaque, target_phys_addr_t addr)
++{
++    ram_addr_t raddr = addr;
++    void *ptr = qemu_get_ram_ptr(raddr);
++    return lduw_p(ptr);
++}
++
++static void subpage_ram_writew(void *opaque, target_phys_addr_t addr,
++                               uint32_t value)
++{
++    ram_addr_t raddr = addr;
++    void *ptr = qemu_get_ram_ptr(raddr);
++    stw_p(ptr, value);
++}
++
++static uint32_t subpage_ram_readl(void *opaque, target_phys_addr_t addr)
++{
++    ram_addr_t raddr = addr;
++    void *ptr = qemu_get_ram_ptr(raddr);
++    return ldl_p(ptr);
++}
++
++static void subpage_ram_writel(void *opaque, target_phys_addr_t addr,
++                               uint32_t value)
++{
++    ram_addr_t raddr = addr;
++    void *ptr = qemu_get_ram_ptr(raddr);
++    stl_p(ptr, value);
++}
++
++static CPUReadMemoryFunc * const subpage_ram_read[] = {
++    &subpage_ram_readb,
++    &subpage_ram_readw,
++    &subpage_ram_readl,
++};
++
++static CPUWriteMemoryFunc * const subpage_ram_write[] = {
++    &subpage_ram_writeb,
++    &subpage_ram_writew,
++    &subpage_ram_writel,
++};
++
+ static int subpage_register (subpage_t *mmio, uint32_t start, uint32_t end,
+                              ram_addr_t memory, ram_addr_t region_offset)
+ {
+@@ -3583,8 +3640,9 @@ static int subpage_register (subpage_t *mmio, uint32_t start, uint32_t end,
+     printf("%s: %p start %08x end %08x idx %08x eidx %08x mem %ld\n", __func__,
+            mmio, start, end, idx, eidx, memory);
+ #endif
+-    if ((memory & ~TARGET_PAGE_MASK) == IO_MEM_RAM)
+-        memory = IO_MEM_UNASSIGNED;
++    if ((memory & ~TARGET_PAGE_MASK) == IO_MEM_RAM) {
++        memory = IO_MEM_SUBPAGE_RAM;
++    }
+     memory = (memory >> IO_MEM_SHIFT) & (IO_MEM_NB_ENTRIES - 1);
+     for (; idx <= eidx; idx++) {
+         mmio->sub_io_index[idx] = memory;
+@@ -3817,6 +3875,9 @@ static void io_mem_init(void)
+     cpu_register_io_memory_fixed(IO_MEM_NOTDIRTY, error_mem_read,
+                                  notdirty_mem_write, NULL,
+                                  DEVICE_NATIVE_ENDIAN);
++    cpu_register_io_memory_fixed(IO_MEM_SUBPAGE_RAM, subpage_ram_read,
++                                 subpage_ram_write, NULL,
++                                 DEVICE_NATIVE_ENDIAN);
+     for (i=0; i<5; i++)
+         io_mem_used[i] = 1;
+
+-- 
+1.7.7.5
+

================================================================
Index: packages/qemu-kvm/0003-hw-9pfs-Improve-portability-to-older-systems.patch
diff -u /dev/null packages/qemu-kvm/0003-hw-9pfs-Improve-portability-to-older-systems.patch:1.1
--- /dev/null	Wed Feb 15 22:39:56 2012
+++ packages/qemu-kvm/0003-hw-9pfs-Improve-portability-to-older-systems.patch	Wed Feb 15 22:39:50 2012
@@ -0,0 +1,101 @@
+From f03969b952bc2aaf9f4445b6da28aebb0a9abde5 Mon Sep 17 00:00:00 2001
+From: "Aneesh Kumar K.V" <aneesh.kumar at linux.vnet.ibm.com>
+Date: Sun, 4 Dec 2011 22:35:27 +0530
+Subject: [PATCH 03/25] hw/9pfs: Improve portability to older systems
+
+handle fs driver require a set of newly added syscalls. Don't
+Compile handle FS driver if those syscalls are not available.
+Instead of adding #ifdef for all those syscalls we check for
+open by handle syscall. If that is available then rest of the
+syscalls used by the driver should be available.
+
+Signed-off-by: Aneesh Kumar K.V <aneesh.kumar at linux.vnet.ibm.com>
+---
+ Makefile.objs              |    4 ++--
+ fsdev/qemu-fsdev.c         |    2 ++
+ hw/9pfs/virtio-9p-handle.c |   33 ---------------------------------
+ 3 files changed, 4 insertions(+), 35 deletions(-)
+
+diff --git a/Makefile.objs b/Makefile.objs
+index d7a6539..3a699ee 100644
+--- a/Makefile.objs
++++ b/Makefile.objs
+@@ -310,8 +310,8 @@ hw-obj-$(CONFIG_SOUND) += $(sound-obj-y)
+ 9pfs-nested-$(CONFIG_VIRTFS) += virtio-9p-local.o virtio-9p-xattr.o
+ 9pfs-nested-$(CONFIG_VIRTFS) += virtio-9p-xattr-user.o virtio-9p-posix-acl.o
+ 9pfs-nested-$(CONFIG_VIRTFS) += virtio-9p-coth.o cofs.o codir.o cofile.o
+-9pfs-nested-$(CONFIG_VIRTFS) += coxattr.o virtio-9p-handle.o
+-9pfs-nested-$(CONFIG_VIRTFS) += virtio-9p-synth.o
++9pfs-nested-$(CONFIG_VIRTFS) += coxattr.o virtio-9p-synth.o
++9pfs-nested-$(CONFIG_OPEN_BY_HANDLE) +=  virtio-9p-handle.o
+
+ hw-obj-$(CONFIG_REALLY_VIRTFS) += $(addprefix 9pfs/, $(9pfs-nested-y))
+ $(addprefix 9pfs/, $(9pfs-nested-y)): QEMU_CFLAGS+=$(GLIB_CFLAGS)
+diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c
+index 7fd2aa7..6684f7e 100644
+--- a/fsdev/qemu-fsdev.c
++++ b/fsdev/qemu-fsdev.c
+@@ -23,7 +23,9 @@ static QTAILQ_HEAD(FsDriverEntry_head, FsDriverListEntry) fsdriver_entries =
+
+ static FsDriverTable FsDrivers[] = {
+     { .name = "local", .ops = &local_ops},
++#ifdef CONFIG_OPEN_BY_HANDLE
+     { .name = "handle", .ops = &handle_ops},
++#endif
+     { .name = "synth", .ops = &synth_ops},
+ };
+
+diff --git a/hw/9pfs/virtio-9p-handle.c b/hw/9pfs/virtio-9p-handle.c
+index 7644ae5..a62f690 100644
+--- a/hw/9pfs/virtio-9p-handle.c
++++ b/hw/9pfs/virtio-9p-handle.c
+@@ -45,7 +45,6 @@ struct handle_data {
+     int handle_bytes;
+ };
+
+-#ifdef CONFIG_OPEN_BY_HANDLE
+ static inline int name_to_handle(int dirfd, const char *name,
+                                  struct file_handle *fh, int *mnt_id, int flags)
+ {
+@@ -56,38 +55,6 @@ static inline int open_by_handle(int mountfd, const char *fh, int flags)
+ {
+     return open_by_handle_at(mountfd, (struct file_handle *)fh, flags);
+ }
+-#else
+-
+-struct rpl_file_handle {
+-    unsigned int handle_bytes;
+-    int handle_type;
+-    unsigned char handle[0];
+-};
+-#define file_handle rpl_file_handle
+-
+-#ifndef AT_REMOVEDIR
+-#define AT_REMOVEDIR    0x200
+-#endif
+-#ifndef AT_EMPTY_PATH
+-#define AT_EMPTY_PATH   0x1000  /* Allow empty relative pathname */
+-#endif
+-#ifndef O_PATH
+-#define O_PATH    010000000
+-#endif
+-
+-static inline int name_to_handle(int dirfd, const char *name,
+-                                 struct file_handle *fh, int *mnt_id, int flags)
+-{
+-    errno = ENOSYS;
+-    return -1;
+-}
+-
+-static inline int open_by_handle(int mountfd, const char *fh, int flags)
+-{
+-    errno = ENOSYS;
+-    return -1;
+-}
+-#endif
+
+ static int handle_update_file_cred(int dirfd, const char *name, FsCred *credp)
+ {
+-- 
+1.7.7.5
+

================================================================
Index: packages/qemu-kvm/0004-hw-9pfs-use-migration-blockers-to-prevent-live-migra.patch
diff -u /dev/null packages/qemu-kvm/0004-hw-9pfs-use-migration-blockers-to-prevent-live-migra.patch:1.1
--- /dev/null	Wed Feb 15 22:39:56 2012
+++ packages/qemu-kvm/0004-hw-9pfs-use-migration-blockers-to-prevent-live-migra.patch	Wed Feb 15 22:39:50 2012
@@ -0,0 +1,171 @@
+From 77a02621812952acfde887244f6f480de1b51f95 Mon Sep 17 00:00:00 2001
+From: "Aneesh Kumar K.V" <aneesh.kumar at linux.vnet.ibm.com>
+Date: Sun, 4 Dec 2011 22:35:28 +0530
+Subject: [PATCH 04/25] hw/9pfs: use migration blockers to prevent live
+ migration when virtfs export path is mounted
+
+Now when you try to migrate with VirtFS export path mounted, you get a proper QMP error:
+
+(qemu) migrate tcp:localhost:4444
+Migration is disabled when VirtFS export path '/tmp/' is mounted in the guest using mount_tag 'v_tmp'
+(qemu)
+
+Signed-off-by: Aneesh Kumar K.V <aneesh.kumar at linux.vnet.ibm.com>
+---
+ hw/9pfs/virtio-9p-device.c |   22 +++++++++++-----------
+ hw/9pfs/virtio-9p.c        |   19 +++++++++++++++++++
+ hw/9pfs/virtio-9p.h        |    5 +++--
+ qerror.c                   |    5 +++++
+ qerror.h                   |    3 +++
+ 5 files changed, 41 insertions(+), 13 deletions(-)
+
+diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
+index bba4c54..c9bca8b 100644
+--- a/hw/9pfs/virtio-9p-device.c
++++ b/hw/9pfs/virtio-9p-device.c
+@@ -33,13 +33,15 @@ static V9fsState *to_virtio_9p(VirtIODevice *vdev)
+
+ static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config)
+ {
++    int len;
+     struct virtio_9p_config *cfg;
+     V9fsState *s = to_virtio_9p(vdev);
+
+-    cfg = g_malloc0(sizeof(struct virtio_9p_config) +
+-                        s->tag_len);
+-    stw_raw(&cfg->tag_len, s->tag_len);
+-    memcpy(cfg->tag, s->tag, s->tag_len);
++    len = strlen(s->tag);
++    cfg = g_malloc0(sizeof(struct virtio_9p_config) + len);
++    stw_raw(&cfg->tag_len, len);
++    /* We don't copy the terminating null to config space */
++    memcpy(cfg->tag, s->tag, len);
+     memcpy(config, cfg, s->config_size);
+     g_free(cfg);
+ }
+@@ -96,20 +98,18 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
+     }
+
+     len = strlen(conf->tag);
+-    if (len > MAX_TAG_LEN) {
++    if (len > MAX_TAG_LEN - 1) {
+         fprintf(stderr, "mount tag '%s' (%d bytes) is longer than "
+-                "maximum (%d bytes)", conf->tag, len, MAX_TAG_LEN);
++                "maximum (%d bytes)", conf->tag, len, MAX_TAG_LEN - 1);
+         exit(1);
+     }
+-    /* s->tag is non-NULL terminated string */
+-    s->tag = g_malloc(len);
+-    memcpy(s->tag, conf->tag, len);
+-    s->tag_len = len;
++
++    s->tag = strdup(conf->tag);
+     s->ctx.uid = -1;
+
+     s->ops = fse->ops;
+     s->vdev.get_features = virtio_9p_get_features;
+-    s->config_size = sizeof(struct virtio_9p_config) + s->tag_len;
++    s->config_size = sizeof(struct virtio_9p_config) + len;
+     s->vdev.get_config = virtio_9p_get_config;
+     s->fid_list = NULL;
+     qemu_co_rwlock_init(&s->rename_lock);
+diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
+index 1b2fc5d..32b98dd 100644
+--- a/hw/9pfs/virtio-9p.c
++++ b/hw/9pfs/virtio-9p.c
+@@ -23,6 +23,7 @@
+ #include "virtio-9p-xattr.h"
+ #include "virtio-9p-coth.h"
+ #include "trace.h"
++#include "migration.h"
+
+ int open_fd_hw;
+ int total_open_fd;
+@@ -373,6 +374,19 @@ static void put_fid(V9fsPDU *pdu, V9fsFidState *fidp)
+      * Don't free the fid if it is in reclaim list
+      */
+     if (!fidp->ref && fidp->clunked) {
++        if (fidp->fid == pdu->s->root_fid) {
++            /*
++             * if the clunked fid is root fid then we
++             * have unmounted the fs on the client side.
++             * delete the migration blocker. Ideally, this
++             * should be hooked to transport close notification
++             */
++            if (pdu->s->migration_blocker) {
++                migrate_del_blocker(pdu->s->migration_blocker);
++                error_free(pdu->s->migration_blocker);
++                pdu->s->migration_blocker = NULL;
++            }
++        }
+         free_fid(pdu, fidp);
+     }
+ }
+@@ -1235,6 +1249,11 @@ static void v9fs_attach(void *opaque)
+     err = offset;
+     trace_v9fs_attach_return(pdu->tag, pdu->id,
+                              qid.type, qid.version, qid.path);
++    s->root_fid = fid;
++    /* disable migration */
++    error_set(&s->migration_blocker, QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION,
++              s->ctx.fs_root, s->tag);
++    migrate_add_blocker(s->migration_blocker);
+ out:
+     put_fid(pdu, fidp);
+ out_nofid:
+diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h
+index 7f88356..8b612da 100644
+--- a/hw/9pfs/virtio-9p.h
++++ b/hw/9pfs/virtio-9p.h
+@@ -246,8 +246,7 @@ typedef struct V9fsState
+     V9fsFidState *fid_list;
+     FileOperations *ops;
+     FsContext ctx;
+-    uint16_t tag_len;
+-    uint8_t *tag;
++    char *tag;
+     size_t config_size;
+     enum p9_proto_version proto_version;
+     int32_t msize;
+@@ -256,6 +255,8 @@ typedef struct V9fsState
+      * on rename.
+      */
+     CoRwlock rename_lock;
++    int32_t root_fid;
++    Error *migration_blocker;
+ } V9fsState;
+
+ typedef struct V9fsStatState {
+diff --git a/qerror.c b/qerror.c
+index fdf62b9..25bc91e 100644
+--- a/qerror.c
++++ b/qerror.c
+@@ -235,6 +235,11 @@ static const QErrorStringTable qerror_table[] = {
+                      "supported by this qemu version: %(feature)",
+     },
+     {
++        .error_fmt = QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION,
++        .desc      = "Migration is disabled when VirtFS export path '%(path)' "
++                     "is mounted in the guest using mount_tag '%(tag)'",
++    },
++    {
+         .error_fmt = QERR_VNC_SERVER_FAILED,
+         .desc      = "Could not start VNC server on %(target)",
+     },
+diff --git a/qerror.h b/qerror.h
+index 2d3d43b..6414cd9 100644
+--- a/qerror.h
++++ b/qerror.h
+@@ -192,6 +192,9 @@ QError *qobject_to_qerror(const QObject *obj);
+ #define QERR_UNKNOWN_BLOCK_FORMAT_FEATURE \
+     "{ 'class': 'UnknownBlockFormatFeature', 'data': { 'device': %s, 'format': %s, 'feature': %s } }"
+
++#define QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION \
++    "{ 'class': 'VirtFSFeatureBlocksMigration', 'data': { 'path': %s, 'tag': %s } }"
++
+ #define QERR_VNC_SERVER_FAILED \
+     "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
+
+-- 
+1.7.7.5
+

================================================================
Index: packages/qemu-kvm/0005-hw-9pfs-Reset-server-state-during-TVERSION.patch
diff -u /dev/null packages/qemu-kvm/0005-hw-9pfs-Reset-server-state-during-TVERSION.patch:1.1
--- /dev/null	Wed Feb 15 22:39:56 2012
+++ packages/qemu-kvm/0005-hw-9pfs-Reset-server-state-during-TVERSION.patch	Wed Feb 15 22:39:50 2012
@@ -0,0 +1,64 @@
+From c554919f74e5a79f15360c4c2f417003477634cf Mon Sep 17 00:00:00 2001
+From: Deepak C Shetty <deepakcs at linux.vnet.ibm.com>
+Date: Sun, 4 Dec 2011 22:35:28 +0530
+Subject: [PATCH 05/25] hw/9pfs: Reset server state during TVERSION
+
+As per the 9p rfc, during TVERSION its necessary to clean all the active
+fids, so that we start the session from a clean state. Its also needed in
+scenarios where the guest is booting off 9p, and boot fails, and client
+restarts, without any knowledge of the past, it will issue a TVERSION again
+so this ensures that we always start from a clean state.
+
+Signed-off-by: Deepak C Shetty <deepakcs at linux.vnet.ibm.com>
+Signed-off-by: Aneesh Kumar K.V <aneesh.kumar at linux.vnet.ibm.com>
+---
+ hw/9pfs/virtio-9p.c |   26 ++++++++++++++++++++++++++
+ 1 files changed, 26 insertions(+), 0 deletions(-)
+
+diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
+index 32b98dd..dd43209 100644
+--- a/hw/9pfs/virtio-9p.c
++++ b/hw/9pfs/virtio-9p.c
+@@ -523,6 +523,30 @@ static int v9fs_mark_fids_unreclaim(V9fsPDU *pdu, V9fsPath *path)
+     return 0;
+ }
+
++static void virtfs_reset(V9fsPDU *pdu)
++{
++    V9fsState *s = pdu->s;
++    V9fsFidState *fidp = NULL;
<<Diff was trimmed, longer than 597 lines>>


More information about the pld-cvs-commit mailing list