qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3] Add remove_boot_device_path() function for h


From: Jun Li
Subject: Re: [Qemu-devel] [PATCH v3] Add remove_boot_device_path() function for hot-unplug device
Date: Wed, 21 May 2014 15:50:37 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

Hi Andreas,


On 05/19/2014 11:31 PM, Andreas Färber wrote:
Hi,

Am 19.05.2014 17:03, schrieb Jun Li:
Add remove_boot_device_path() function to remove bootindex when hot-unplug
a device. This patch fixed virtio-blk/virtio-net/scsi-disk/scsi-generic device.

Signed-off-by: Jun Li <address@hidden>
---
This patch also fixed bug1086603, ref:
https://bugzilla.redhat.com/show_bug.cgi?id=1086603

This version of patch delete dev and suffix parameter from function 
remove_boot_device_path().
---
  hw/block/virtio-blk.c   |  1 +
  hw/net/virtio-net.c     |  1 +
  hw/scsi/scsi-disk.c     |  1 +
  hw/scsi/scsi-generic.c  |  1 +
On v1 I believe I reminded you of spapr_llan. Your patch is adding a new
remove_*() function, but is using it only for roughly half of the
devices that currently call add_boot_device_path(). Why? I can
understand that ISA devices will not be hot-unpluggable, but all PCI and
USB devices are.

Yes, as I am not so family with spapr_llan, so just fixed roughly half of the devices. I have checked the following files.

hw/block/fdc.c:    add_boot_device_path(isa->bootindexA, dev, 
"/address@hidden");

No need here, ISA not support hot-unplug.

hw/block/fdc.c:    add_boot_device_path(isa->bootindexB, dev, 
"/address@hidden");

No need here, ISA not support hot-unplug.

hw/block/virtio-blk.c:    add_boot_device_path(s->conf->bootindex, dev,
"/address@hidden,0");

Has done.

hw/core/loader.c:    add_boot_device_path(bootindex, NULL, devpath);

No need here.

hw/i386/kvm/pci-assign.c:    add_boot_device_path(dev->bootindex,
&pci_dev->qdev, NULL);

I will add in assigned_exitfn().

hw/ide/qdev.c:    add_boot_device_path(dev->conf.bootindex, &dev->qdev,

ide doesn't support hot-unplug. so no need here.

hw/misc/vfio.c:    add_boot_device_path(vdev->bootindex, &pdev->qdev, NULL);

I will add in vfio_exitfn().

hw/net/e1000.c:    add_boot_device_path(d->conf.bootindex, dev,
"/address@hidden");

I will add in pci_e1000_uninit().

hw/net/eepro100.c:    add_boot_device_path(s->conf.bootindex,
&pci_dev->qdev, "/address@hidden");

I will add in pci_nic_uninit().

hw/net/ne2000.c:    add_boot_device_path(s->c.bootindex, &pci_dev->qdev,
"/address@hidden");

I will add in ci_ne2000_exit().

hw/net/pcnet.c:    add_boot_device_path(s->conf.bootindex, dev,
"/address@hidden");

No need here.

hw/net/rtl8139.c:    add_boot_device_path(s->conf.bootindex, d,
"/address@hidden");

I will in add pci_rtl8139_uninit().

hw/net/spapr_llan.c:    add_boot_device_path(dev->nicconf.bootindex,
DEVICE(dev), "");

No need here.

hw/net/virtio-net.c:    add_boot_device_path(n->nic_conf.bootindex, dev,
"/address@hidden");

I will add in virtio_net_device_unrealize().

hw/net/vmxnet3.c:    add_boot_device_path(s->conf.bootindex, dev,
"/address@hidden");

I will add in vmxnet3_pci_uninit().

hw/scsi/scsi-disk.c:    add_boot_device_path(s->qdev.conf.bootindex,
&dev->qdev, NULL);

has done.

hw/scsi/scsi-generic.c:        add_boot_device_path(s->conf.bootindex,
&s->qdev, NULL);

it doesn't support hot-unplug, so no need here.

hw/usb/dev-network.c:    add_boot_device_path(s->conf.bootindex,
&dev->qdev, "/address@hidden");

no need here.

hw/usb/host-libusb.c:    add_boot_device_path(s->bootindex, &udev->qdev,
NULL);

No need here.

hw/usb/redirect.c:    add_boot_device_path(dev->bootindex, &udev->qdev,
NULL);

No need here. Generic pass-through doesn't support hot-unplug.


  include/sysemu/sysemu.h |  1 +
  vl.c                    | 15 +++++++++++++++
  6 files changed, 20 insertions(+)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 8a568e5..497eb40 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -752,6 +752,7 @@ static void virtio_blk_device_unrealize(DeviceState *dev, 
Error **errp)
      unregister_savevm(dev, "virtio-blk", s);
      blockdev_mark_auto_del(s->bs);
      virtio_cleanup(vdev);
+    remove_boot_device_path(s->conf->bootindex);
  }
static Property virtio_blk_properties[] = {
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 940a7cf..6afb1ca 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1645,6 +1645,7 @@ static void virtio_net_device_unrealize(DeviceState *dev, 
Error **errp)
      g_free(n->vqs);
      qemu_del_nic(n->nic);
      virtio_cleanup(vdev);
+    remove_boot_device_path(n->nic_conf.bootindex);
  }
static void virtio_net_instance_init(Object *obj)
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 4bcef55..d33df2e 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -2156,6 +2156,7 @@ static void scsi_destroy(SCSIDevice *dev)
scsi_device_purge_requests(&s->qdev, SENSE_CODE(NO_SENSE));
      blockdev_mark_auto_del(s->qdev.conf.bs);
+    remove_boot_device_path(s->qdev.conf.bootindex);
Didn't I previously ask that you use dev->config.bootindex here?
Pointers to parent's struct shouldn't be accessed anywhere except
VMStateDescription.

ok.

  }
static void scsi_disk_resize_cb(void *opaque)
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index 3733d2c..d387f3e 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -390,6 +390,7 @@ static void scsi_destroy(SCSIDevice *s)
  {
      scsi_device_purge_requests(s, SENSE_CODE(NO_SENSE));
      blockdev_mark_auto_del(s->conf.bs);
+    remove_boot_device_path(s->conf.bootindex);
  }
static int scsi_generic_initfn(SCSIDevice *s)
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index ba5c7f8..2510e3b 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -193,6 +193,7 @@ void rtc_change_mon_event(struct tm *tm);
void add_boot_device_path(int32_t bootindex, DeviceState *dev,
                            const char *suffix);
+void remove_boot_device_path(int32_t bootindex);
  char *get_boot_devices_list(size_t *size, bool ignore_suffixes);
DeviceState *get_boot_device(uint32_t position);
diff --git a/vl.c b/vl.c
index 709d8cd..f31d008 100644
--- a/vl.c
+++ b/vl.c
@@ -1189,6 +1189,21 @@ void add_boot_device_path(int32_t bootindex, DeviceState 
*dev,
      QTAILQ_INSERT_TAIL(&fw_boot_order, node, link);
  }
+void remove_boot_device_path(int32_t bootindex)
+{
+    FWBootEntry *node, *next_node;
+
+    if (bootindex == -1) {
+        return;
+    }
+
+    QTAILQ_FOREACH_SAFE(node, &fw_boot_order, link, next_node)
Coding Style requires braces around the below single-statement if.

ok. I will submit a update version later. Thank you very much.


Best Regards,
Jun Li



reply via email to

[Prev in Thread] Current Thread [Next in Thread]