From patchwork Wed May 21 16:12:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: lijun X-Patchwork-Id: 351236 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0EF86140084 for ; Thu, 22 May 2014 02:13:59 +1000 (EST) Received: from localhost ([::1]:60771 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wn99Q-0002rd-Qo for incoming@patchwork.ozlabs.org; Wed, 21 May 2014 12:13:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wn98v-0002CX-5b for qemu-devel@nongnu.org; Wed, 21 May 2014 12:13:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wn98m-0005HC-0x for qemu-devel@nongnu.org; Wed, 21 May 2014 12:13:25 -0400 Received: from mail-pb0-x22a.google.com ([2607:f8b0:400e:c01::22a]:36107) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wn98l-0005H3-MQ for qemu-devel@nongnu.org; Wed, 21 May 2014 12:13:15 -0400 Received: by mail-pb0-f42.google.com with SMTP id md12so1561759pbc.29 for ; Wed, 21 May 2014 09:13:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=gNVTOCqXVxwlUQnOKoE3Ab2H3rtzklXLCa8OZ6qreXk=; b=DVj0FqKJx//k7noLunrgF9pFPjW6DjWrUJES+gqErg/S/tYJFep2p3f1MSH4/5129I xEboQjM9Ya25gdIwnOUBscH9Bplgwa7ykspb43CsxCCd6BXnPxQuThr2NE9UV+9XfwTu lZLAnU0AMRxNJ6cXh/KCgDnwm5LICYCsQDMhI25GLsZ8Z5ZeNoHtFy6dTYLXe8LwtYc6 me0xNs3nndrcQbN2is9Y+y2sMUAEiAxLPJPwnQUAK57kW9aZp19wAC+KDX9GxspyoLl0 t/VDNxoFnJMbrK7VJhv3edYNSYNesJ4e+e0mdz7WX30tJi0sr16hmOza51L+1YNSxNVJ +CfA== X-Received: by 10.66.242.204 with SMTP id ws12mr60620098pac.10.1400688794710; Wed, 21 May 2014 09:13:14 -0700 (PDT) Received: from localhost ([125.39.108.75]) by mx.google.com with ESMTPSA id ak1sm39619438pac.16.2014.05.21.09.12.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 May 2014 09:13:13 -0700 (PDT) From: Jun Li To: qemu-devel@nongnu.org Date: Thu, 22 May 2014 00:12:06 +0800 Message-Id: <1400688726-22217-1-git-send-email-junmuzi@gmail.com> X-Mailer: git-send-email 1.9.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c01::22a Cc: kwolf@redhat.com, famz@redhat.com, stefanha@redhat.com, mst@redhat.com, Jun Li , marcel.a@redhat.com, juli@redhat.com, aliguori@amazon.com, pbonzini@redhat.com, lersek@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH v4] Add remove_boot_device_path() function for hot-unplug device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add remove_boot_device_path() function to remove bootindex when hot-unplug a device. Signed-off-by: Jun Li --- hw/block/virtio-blk.c | 1 + hw/i386/kvm/pci-assign.c | 1 + hw/misc/vfio.c | 1 + hw/net/e1000.c | 1 + hw/net/eepro100.c | 1 + hw/net/ne2000.c | 1 + hw/net/rtl8139.c | 1 + hw/net/spapr_llan.c | 2 ++ hw/net/virtio-net.c | 1 + hw/net/vmxnet3.c | 2 ++ hw/scsi/scsi-disk.c | 1 + hw/scsi/scsi-generic.c | 1 + hw/usb/dev-network.c | 1 + hw/usb/host-libusb.c | 1 + hw/usb/redirect.c | 1 + include/sysemu/sysemu.h | 1 + vl.c | 16 ++++++++++++++++ 17 files changed, 34 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/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c index de33657..e655c8c 100644 --- a/hw/i386/kvm/pci-assign.c +++ b/hw/i386/kvm/pci-assign.c @@ -1855,6 +1855,7 @@ static void assigned_exitfn(struct PCIDevice *pci_dev) deassign_device(dev); free_assigned_device(dev); + remove_boot_device_path(dev->bootindex); } static Property assigned_dev_properties[] = { diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c index 9cf5b84..1fea17d 100644 --- a/hw/misc/vfio.c +++ b/hw/misc/vfio.c @@ -3900,6 +3900,7 @@ static void vfio_exitfn(PCIDevice *pdev) g_free(vdev->rom); vfio_put_device(vdev); vfio_put_group(group); + remove_boot_device_path(vdev->bootindex); } static void vfio_pci_reset(DeviceState *dev) diff --git a/hw/net/e1000.c b/hw/net/e1000.c index 8387443..190a9b1 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -1491,6 +1491,7 @@ pci_e1000_uninit(PCIDevice *dev) memory_region_destroy(&d->mmio); memory_region_destroy(&d->io); qemu_del_nic(d->nic); + remove_boot_device_path(d->conf.bootindex); } static NetClientInfo net_e1000_info = { diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index 3b891ca..54924a4 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -1850,6 +1850,7 @@ static void pci_nic_uninit(PCIDevice *pci_dev) vmstate_unregister(&pci_dev->qdev, s->vmstate, s); eeprom93xx_free(&pci_dev->qdev, s->eeprom); qemu_del_nic(s->nic); + remove_boot_device_path(s->conf.bootindex); } static NetClientInfo net_eepro100_info = { diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c index 4c32e9e..53ef57a 100644 --- a/hw/net/ne2000.c +++ b/hw/net/ne2000.c @@ -753,6 +753,7 @@ static void pci_ne2000_exit(PCIDevice *pci_dev) memory_region_destroy(&s->io); qemu_del_nic(s->nic); qemu_free_irq(s->irq); + remove_boot_device_path(s->c.bootindex); } static Property ne2000_properties[] = { diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c index 5329f44..a6b6130 100644 --- a/hw/net/rtl8139.c +++ b/hw/net/rtl8139.c @@ -3474,6 +3474,7 @@ static void pci_rtl8139_uninit(PCIDevice *dev) timer_del(s->timer); timer_free(s->timer); qemu_del_nic(s->nic); + remove_boot_device_path(s->conf.bootindex); } static void rtl8139_set_link_status(NetClientState *nc) diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c index c433337..8fbd5b1 100644 --- a/hw/net/spapr_llan.c +++ b/hw/net/spapr_llan.c @@ -185,6 +185,8 @@ static void spapr_vlan_cleanup(NetClientState *nc) VIOsPAPRVLANDevice *dev = qemu_get_nic_opaque(nc); dev->nic = NULL; + + remove_boot_device_path(dev->nicconf.bootindex); } static NetClientInfo net_spapr_vlan_info = { 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/net/vmxnet3.c b/hw/net/vmxnet3.c index 1bb9259..20a657c 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -2186,6 +2186,8 @@ static void vmxnet3_pci_uninit(PCIDevice *pci_dev) memory_region_destroy(&s->bar0); memory_region_destroy(&s->bar1); memory_region_destroy(&s->msix_bar); + + remove_boot_device_path(s->conf.bootindex); } static void vmxnet3_qdev_reset(DeviceState *dev) 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); } 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/hw/usb/dev-network.c b/hw/usb/dev-network.c index 518d536..3aab429 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -1331,6 +1331,7 @@ static void usb_net_handle_destroy(USBDevice *dev) /* TODO: remove the nd_table[] entry */ rndis_clear_responsequeue(s); qemu_del_nic(s->nic); + remove_boot_device_path(s->conf.bootindex); } static NetClientInfo net_usbnet_info = { diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index 57bed09..3026258 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -920,6 +920,7 @@ static void usb_host_handle_destroy(USBDevice *udev) qemu_remove_exit_notifier(&s->exit); QTAILQ_REMOVE(&hostdevs, s, next); usb_host_close(s); + remove_boot_device_path(s->bootindex); } static void usb_host_cancel_packet(USBDevice *udev, USBPacket *p) diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 287a505..27dc173 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -1351,6 +1351,7 @@ static void usbredir_handle_destroy(USBDevice *udev) } free(dev->filter_rules); + remove_boot_device_path(dev->bootindex); } static int usbredir_check_filter(USBRedirDevice *dev) 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..dd4049e 100644 --- a/vl.c +++ b/vl.c @@ -1189,6 +1189,22 @@ 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) { + if (node->bootindex == bootindex) { + QTAILQ_REMOVE(&fw_boot_order, node, link); + return; + } + } +} + DeviceState *get_boot_device(uint32_t position) { uint32_t counter = 0;