Re: [Qemu-devel] [PATCH] console: nicer initial screen

2013-06-11 Thread Gerd Hoffmann
  Hi,

 This patch adds a text line to the in initial DisplaySurface, notifying
 the user that the display isn't initialized yet by the guest.

 Dunno if I said this in the previous posting, but what about just
 blitting an image?

Why?  And which one?

 This text isn't internationalized.

We can change that without too much fuss I think, now that we have the
gettext infrastructure anyway for the gtk ui ...

cheers,
  Gerd





Re: [Qemu-devel] [PATCH 1/2] fbdev: add linux framebuffer display driver.

2013-06-11 Thread Gerd Hoffmann
  Hi,

 +static QEMUCursor *ptr_cursor;
 +static pixman_image_t *ptr_image;
 +static intptr_refresh;
 +static intpx, py, pw, ph;
 +static intmx, my, mon;
 +
 +/* options */
 +static intuse_scale;
 +static pixman_filter_tpfilter = PIXMAN_FILTER_GOOD;
 
 Should stick all of this within a structure and pass it around where
 possible.

Don't see what this buys us as there can be only a single framebuffer
display anyway.  Can do that though.

 +if (qemu_console_is_graphic(NULL)) {
 +send_scancode(keycode, up);
 +} else if (!up) {
 +send_keysym(keycode, shift);
 
 I'm confused here...  Why can't use use the normal keymap code with the
 keycode value?

keycode != keycode.  qemu uses ps/2 keycodes.  fbdev gets linux input
layer keycodes as input.

cheers,
  Gerd





Re: [Qemu-devel] [PATCH] virtio-scsi: forward scsibus for virtio-scsi-pci.

2013-06-11 Thread Frederic Konrad

On 10/06/2013 19:00, Michael S. Tsirkin wrote:

On Mon, Jun 10, 2013 at 11:53:04AM +0200, fred.kon...@greensocs.com wrote:

From: KONRAD Frederic fred.kon...@greensocs.com

This fix a bug with scsi hotplug on virtio-scsi-pci:

As virtio-scsi-pci doesn't have any scsi bus, we need to forward scsi-hot-add
to the virtio-scsi-device plugged on the virtio-bus.

Reported-by: Alexey Kardashevskiy a...@ozlabs.ru
Signed-off-by: KONRAD Frederic fred.kon...@greensocs.com
---
  hw/pci/pci-hotplug.c | 19 +--
  1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/hw/pci/pci-hotplug.c b/hw/pci/pci-hotplug.c
index 12287d1..c708752 100644
--- a/hw/pci/pci-hotplug.c
+++ b/hw/pci/pci-hotplug.c
@@ -30,6 +30,8 @@
  #include monitor/monitor.h
  #include hw/scsi/scsi.h
  #include hw/virtio/virtio-blk.h
+#include hw/virtio/virtio-scsi.h
+#include hw/virtio/virtio-pci.h
  #include qemu/config-file.h
  #include sysemu/blockdev.h
  #include qapi/error.h
@@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState *adapter,
  {
  SCSIBus *scsibus;
  SCSIDevice *scsidev;
+VirtIOPCIProxy *virtio_proxy;
  
  scsibus = (SCSIBus *)

  object_dynamic_cast(OBJECT(QLIST_FIRST(adapter-child_bus)),
  TYPE_SCSI_BUS);
  if (!scsibus) {
-   error_report(Device is not a SCSI adapter);
-   return -1;
+/*
+ * Check if the adapter is a virtio-scsi-pci, and forward scsi_hot_add
+ * to the virtio-scsi-device.
+ */
+if (!object_dynamic_cast(OBJECT(adapter), TYPE_VIRTIO_SCSI_PCI)) {
+error_report(Device is not a SCSI adapter);
+return -1;
+}
+virtio_proxy = VIRTIO_PCI(adapter);
+adapter = DEVICE(virtio_proxy-bus.vdev);
+scsibus = (SCSIBus *)
+  object_dynamic_cast(OBJECT(QLIST_FIRST(adapter-child_bus)),
+TYPE_SCSI_BUS);
+assert(scsibus);
  }
  
  /*

By the way I really wonder. pci-hotplug.c was supposed to
be legacy interface.
Is this the only way to add scsi disks?
And are other ways broken, too?


Here you can add scsi disks to a given device.
I think the other ways add scsi disks to a given bus?

Do you see any other?

Thanks,
Fred



--
1.8.1.4





[Qemu-devel] [RFT PATCH v1 00/30] PCI: Cleanup legacy casts in device land

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

There are a number of different cast implementations from various
stages of QEMU development out in device model land. This series cleans
up the ones involving TYPE_PCI_DEVICE to consistently use proper QOM
casts for both up and down casts.

Some were easy, some needed QOM cast macros which are added as
appropriate.

Following the recent discussion RE performance consequences of QOM
casts, im interested in any reports of possible performance regressions
here, although I am hoping that Anthony current efforts to improve
QOM casting efficiency make this a non-issue.


Peter Crosthwaite (30):
  net/e1000: QOM Upcast Sweep
  net/rtl8139: QOM Upcast Sweep
  net/pcnet-pci: QOM Upcast Sweep
  usb/hcd-xhci: QOM Upcast Sweep
  scsi/lsi53c895a: QOM Upcast Sweep
  scsi/megasas: QOM Upcast Sweep
  scsi/esp-pci: QOM Upcast Sweep
  ide/ich: QOM Upcast Sweep
  ide/piix: QOM casting sweep
  acpi/piix4: QOM Upcast Sweep
  misc/pci-testdev: QOM Upcast Sweep
  virtio/virtio-pci: QOM casting sweep
  virtio/vmware_vga: QOM casting sweep
  misc/ivshmem: QOM Upcast Sweep
  xen/xen_platform: QOM casting sweep
  isa/*: QOM casting sweep
  pci/*: QOM casting sweep
  pci-bridge/pci_bridge_dev: Don't use DO_UPCAST
  pci-bridge/*: substitute -qdev casts with DEVICE()
  misc/vfio: substitute -qdev casts with DEVICE()
  net/eepro100: substitute -qdev casts with DEVICE()
  net/ne2000: substitute -qdev casts with DEVICE()
  usb/*: substitute -qdev casts with DEVICE()
  watchdog/wdt_i6300esb: substitute -qdev casts with DEVICE()
  scsi/vmw_pvscsi: substitute -qdev casts with DEVICE()
  i2c/smbus_ich9: substitute -qdev casts with DEVICE()
  ide/cmd646: substitute -qdev casts with DEVICE()
  ide/via: substitute -qdev casts with DEVICE()
  pci-host/*: substitute -qdev casts with DEVICE()
  i386/*: substitute -qdev casts with DEVICE()

 hw/acpi/piix4.c| 31 +--
 hw/display/vmware_vga.c| 13 -
 hw/i2c/smbus_ich9.c|  2 +-
 hw/i386/kvm/pci-assign.c   | 21 -
 hw/i386/pc.c   |  4 ++--
 hw/i386/pc_piix.c  |  4 ++--
 hw/i386/pc_q35.c   |  4 ++--
 hw/ide/ahci.h  |  5 +
 hw/ide/cmd646.c|  8 
 hw/ide/ich.c   | 10 +-
 hw/ide/piix.c  |  8 
 hw/ide/via.c   |  4 ++--
 hw/isa/i82378.c|  8 
 hw/isa/lpc_ich9.c  |  6 +++---
 hw/isa/piix4.c |  4 ++--
 hw/isa/vt82c686.c  | 14 +++---
 hw/misc/ivshmem.c  | 18 +++---
 hw/misc/pci-testdev.c  | 11 ---
 hw/misc/vfio.c |  4 ++--
 hw/net/e1000.c | 20 +---
 hw/net/eepro100.c  | 14 --
 hw/net/ne2000.c|  6 --
 hw/net/pcnet-pci.c | 14 +-
 hw/net/rtl8139.c   | 26 ++
 hw/pci-bridge/dec.c|  2 +-
 hw/pci-bridge/i82801b11.c  |  2 +-
 hw/pci-bridge/ioh3420.c|  2 +-
 hw/pci-bridge/pci_bridge_dev.c |  2 +-
 hw/pci-bridge/xio3130_downstream.c |  2 +-
 hw/pci-bridge/xio3130_upstream.c   |  2 +-
 hw/pci-host/apb.c  |  4 ++--
 hw/pci-host/q35.c  |  4 ++--
 hw/pci/pci-hotplug.c   | 18 ++
 hw/pci/pci.c   | 17 +
 hw/pci/pci_bridge.c|  7 ---
 hw/pci/pcie.c  |  4 ++--
 hw/pci/shpc.c  |  8 
 hw/scsi/esp-pci.c  | 14 +-
 hw/scsi/lsi53c895a.c   | 26 --
 hw/scsi/megasas.c  | 17 +++--
 hw/scsi/vmw_pvscsi.c   |  2 +-
 hw/usb/hcd-ehci-pci.c  | 13 -
 hw/usb/hcd-ohci.c  |  2 +-
 hw/usb/hcd-uhci.c  |  2 +-
 hw/usb/hcd-xhci.c  | 19 +--
 hw/virtio/virtio-pci.c |  4 ++--
 hw/watchdog/wdt_i6300esb.c |  2 +-
 hw/xen/xen_platform.c  | 28 
 48 files changed, 271 insertions(+), 191 deletions(-)

-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 02/30] net/rtl8139: QOM Upcast Sweep

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Define and use standard QOM cast macro. Remove usages of DO_UPCAST
and direct - style upcasting.

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/net/rtl8139.c | 26 ++
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index 7993f9f..955d35e 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -92,6 +92,11 @@ static inline GCC_FMT_ATTR(1, 2) int DPRINTF(const char 
*fmt, ...)
 }
 #endif
 
+#define TYPE_RTL8139 rtl8139
+
+#define RTL8139(obj) \
+ OBJECT_CHECK(RTL8139State, (obj), TYPE_RTL8139)
+
 /* Symbolic offsets to registers. */
 enum RTL8139_registers {
 MAC0 = 0,/* Ethernet hardware address. */
@@ -1197,7 +1202,7 @@ static void rtl8139_reset_rxring(RTL8139State *s, 
uint32_t bufferSize)
 
 static void rtl8139_reset(DeviceState *d)
 {
-RTL8139State *s = container_of(d, RTL8139State, dev.qdev);
+RTL8139State *s = RTL8139(d);
 int i;
 
 /* restore MAC address */
@@ -1364,6 +1369,8 @@ static const VMStateDescription vmstate_tally_counters = {
 
 static void rtl8139_ChipCmd_write(RTL8139State *s, uint32_t val)
 {
+DeviceState *d = DEVICE(s);
+
 val = 0xff;
 
 DPRINTF(ChipCmd write val=0x%08x\n, val);
@@ -1371,7 +1378,7 @@ static void rtl8139_ChipCmd_write(RTL8139State *s, 
uint32_t val)
 if (val  CmdReset)
 {
 DPRINTF(ChipCmd reset\n);
-rtl8139_reset(s-dev.qdev);
+rtl8139_reset(d);
 }
 if (val  CmdRxEnb)
 {
@@ -1525,6 +1532,8 @@ static uint32_t rtl8139_BasicModeStatus_read(RTL8139State 
*s)
 
 static void rtl8139_Cfg9346_write(RTL8139State *s, uint32_t val)
 {
+DeviceState *d = DEVICE(s);
+
 val = 0xff;
 
 DPRINTF(Cfg9346 write val=0x%02x\n, val);
@@ -1544,7 +1553,7 @@ static void rtl8139_Cfg9346_write(RTL8139State *s, 
uint32_t val)
 } else if (opmode == 0x40) {
 /* Reset.  */
 val = 0;
-rtl8139_reset(s-dev.qdev);
+rtl8139_reset(d);
 }
 
 s-Cfg9346 = val;
@@ -3439,7 +3448,7 @@ static void rtl8139_cleanup(NetClientState *nc)
 
 static void pci_rtl8139_uninit(PCIDevice *dev)
 {
-RTL8139State *s = DO_UPCAST(RTL8139State, dev, dev);
+RTL8139State *s = RTL8139(dev);
 
 memory_region_destroy(s-bar_io);
 memory_region_destroy(s-bar_mem);
@@ -3477,7 +3486,8 @@ static NetClientInfo net_rtl8139_info = {
 
 static int pci_rtl8139_init(PCIDevice *dev)
 {
-RTL8139State * s = DO_UPCAST(RTL8139State, dev, dev);
+RTL8139State *s = RTL8139(dev);
+DeviceState *d = DEVICE(dev);
 uint8_t *pci_conf;
 
 pci_conf = s-dev.config;
@@ -3505,7 +3515,7 @@ static int pci_rtl8139_init(PCIDevice *dev)
 s-eeprom.contents[9] = s-conf.macaddr.a[4] | s-conf.macaddr.a[5]  8;
 
 s-nic = qemu_new_nic(net_rtl8139_info, s-conf,
-  object_get_typename(OBJECT(dev)), dev-qdev.id, s);
+  object_get_typename(OBJECT(dev)), d-id, s);
 qemu_format_nic_info_str(qemu_get_queue(s-nic), s-conf.macaddr.a);
 
 s-cplus_txbuffer = NULL;
@@ -3516,7 +3526,7 @@ static int pci_rtl8139_init(PCIDevice *dev)
 s-timer = qemu_new_timer_ns(vm_clock, rtl8139_timer, s);
 rtl8139_set_next_tctr_time(s, qemu_get_clock_ns(vm_clock));
 
-add_boot_device_path(s-conf.bootindex, dev-qdev, /ethernet-phy@0);
+add_boot_device_path(s-conf.bootindex, d, /ethernet-phy@0);
 
 return 0;
 }
@@ -3544,7 +3554,7 @@ static void rtl8139_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo rtl8139_info = {
-.name  = rtl8139,
+.name  = TYPE_RTL8139,
 .parent= TYPE_PCI_DEVICE,
 .instance_size = sizeof(RTL8139State),
 .class_init= rtl8139_class_init,
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 01/30] net/e1000: QOM Upcast Sweep

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Define and use standard QOM cast macro. Remove usages of DO_UPCAST
and direct - style upcasting.

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/net/e1000.c | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index e6f46f0..a7de400 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -138,6 +138,11 @@ typedef struct E1000State_st {
 uint32_t compat_flags;
 } E1000State;
 
+#define TYPE_E1000 e1000
+
+#define E1000(obj) \
+OBJECT_CHECK(E1000State, (obj), TYPE_E1000)
+
 #definedefreg(x)   x = (E1000_##x2)
 enum {
 defreg(CTRL),  defreg(EECD),   defreg(EERD),   defreg(GPRC),
@@ -1175,7 +1180,7 @@ static int e1000_post_load(void *opaque, int version_id)
 }
 
 static const VMStateDescription vmstate_e1000 = {
-.name = e1000,
+.name = TYPE_E1000,
 .version_id = 2,
 .minimum_version_id = 1,
 .minimum_version_id_old = 1,
@@ -1296,7 +1301,7 @@ e1000_cleanup(NetClientState *nc)
 static void
 pci_e1000_uninit(PCIDevice *dev)
 {
-E1000State *d = DO_UPCAST(E1000State, dev, dev);
+E1000State *d = E1000(dev);
 
 qemu_del_timer(d-autoneg_timer);
 qemu_free_timer(d-autoneg_timer);
@@ -1316,7 +1321,8 @@ static NetClientInfo net_e1000_info = {
 
 static int pci_e1000_init(PCIDevice *pci_dev)
 {
-E1000State *d = DO_UPCAST(E1000State, dev, pci_dev);
+DeviceState *dev = DEVICE(pci_dev);
+E1000State *d = E1000(pci_dev);
 uint8_t *pci_conf;
 uint16_t checksum = 0;
 int i;
@@ -1347,11 +1353,11 @@ static int pci_e1000_init(PCIDevice *pci_dev)
 d-eeprom_data[EEPROM_CHECKSUM_REG] = checksum;
 
 d-nic = qemu_new_nic(net_e1000_info, d-conf,
-  object_get_typename(OBJECT(d)), d-dev.qdev.id, d);
+  object_get_typename(OBJECT(d)), dev-id, d);
 
 qemu_format_nic_info_str(qemu_get_queue(d-nic), macaddr);
 
-add_boot_device_path(d-conf.bootindex, pci_dev-qdev, /ethernet-phy@0);
+add_boot_device_path(d-conf.bootindex, dev, /ethernet-phy@0);
 
 d-autoneg_timer = qemu_new_timer_ms(vm_clock, e1000_autoneg_timer, d);
 
@@ -1360,7 +1366,7 @@ static int pci_e1000_init(PCIDevice *pci_dev)
 
 static void qdev_e1000_reset(DeviceState *dev)
 {
-E1000State *d = DO_UPCAST(E1000State, dev.qdev, dev);
+E1000State *d = E1000(dev);
 e1000_reset(d);
 }
 
@@ -1390,7 +1396,7 @@ static void e1000_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo e1000_info = {
-.name  = e1000,
+.name  = TYPE_E1000,
 .parent= TYPE_PCI_DEVICE,
 .instance_size = sizeof(E1000State),
 .class_init= e1000_class_init,
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 03/30] net/pcnet-pci: QOM Upcast Sweep

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Define and use standard QOM cast macro. Remove usages of DO_UPCAST
and direct - style upcasting.

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/net/pcnet-pci.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/hw/net/pcnet-pci.c b/hw/net/pcnet-pci.c
index 9df2b87..b1afbf4 100644
--- a/hw/net/pcnet-pci.c
+++ b/hw/net/pcnet-pci.c
@@ -43,6 +43,10 @@
 //#define PCNET_DEBUG_TMD
 //#define PCNET_DEBUG_MATCH
 
+#define TYPE_PCI_PC_NET pcnet
+
+#define PCI_PC_NET(obj) \
+ OBJECT_CHECK(PCIPCNetState, (obj), TYPE_PCI_PC_NET)
 
 typedef struct {
 PCIDevice pci_dev;
@@ -273,7 +277,7 @@ static void pci_pcnet_cleanup(NetClientState *nc)
 
 static void pci_pcnet_uninit(PCIDevice *dev)
 {
-PCIPCNetState *d = DO_UPCAST(PCIPCNetState, pci_dev, dev);
+PCIPCNetState *d = PCI_PC_NET(dev);
 
 memory_region_destroy(d-state.mmio);
 memory_region_destroy(d-io_bar);
@@ -293,7 +297,7 @@ static NetClientInfo net_pci_pcnet_info = {
 
 static int pci_pcnet_init(PCIDevice *pci_dev)
 {
-PCIPCNetState *d = DO_UPCAST(PCIPCNetState, pci_dev, pci_dev);
+PCIPCNetState *d = PCI_PC_NET(pci_dev);
 PCNetState *s = d-state;
 uint8_t *pci_conf;
 
@@ -329,12 +333,12 @@ static int pci_pcnet_init(PCIDevice *pci_dev)
 s-phys_mem_write = pci_physical_memory_write;
 s-dma_opaque = pci_dev;
 
-return pcnet_common_init(pci_dev-qdev, s, net_pci_pcnet_info);
+return pcnet_common_init(DEVICE(pci_dev), s, net_pci_pcnet_info);
 }
 
 static void pci_reset(DeviceState *dev)
 {
-PCIPCNetState *d = DO_UPCAST(PCIPCNetState, pci_dev.qdev, dev);
+PCIPCNetState *d = PCI_PC_NET(dev);
 
 pcnet_h_reset(d-state);
 }
@@ -362,7 +366,7 @@ static void pcnet_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo pcnet_info = {
-.name  = pcnet,
+.name  = TYPE_PCI_PC_NET,
 .parent= TYPE_PCI_DEVICE,
 .instance_size = sizeof(PCIPCNetState),
 .class_init= pcnet_class_init,
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 04/30] usb/hcd-xhci: QOM Upcast Sweep

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Define and use standard QOM cast macro. Remove usages of DO_UPCAST
and direct - style upcasting.

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/usb/hcd-xhci.c | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 91633ed..0146711 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -482,6 +482,11 @@ struct XHCIState {
 XHCIRing cmd_ring;
 };
 
+#define TYPE_XHCI nec-usb-xhci
+
+#define XHCI(obj) \
+OBJECT_CHECK(XHCIState, (obj), TYPE_XHCI)
+
 typedef struct XHCIEvRingSeg {
 uint32_t addr_low;
 uint32_t addr_high;
@@ -2681,7 +2686,7 @@ static void xhci_port_reset(XHCIPort *port)
 
 static void xhci_reset(DeviceState *dev)
 {
-XHCIState *xhci = DO_UPCAST(XHCIState, pci_dev.qdev, dev);
+XHCIState *xhci = XHCI(dev);
 int i;
 
 trace_usb_xhci_reset();
@@ -2926,6 +2931,7 @@ static void xhci_oper_write(void *ptr, hwaddr reg,
 uint64_t val, unsigned size)
 {
 XHCIState *xhci = ptr;
+DeviceState *d = DEVICE(ptr);
 
 trace_usb_xhci_oper_write(reg, val);
 
@@ -2939,7 +2945,7 @@ static void xhci_oper_write(void *ptr, hwaddr reg,
 xhci-usbcmd = val  0xc0f;
 xhci_mfwrap_update(xhci);
 if (val  USBCMD_HCRST) {
-xhci_reset(xhci-pci_dev.qdev);
+xhci_reset(d);
 }
 xhci_intx_update(xhci);
 break;
@@ -3267,6 +3273,7 @@ static USBBusOps xhci_bus_ops = {
 
 static void usb_xhci_init(XHCIState *xhci, DeviceState *dev)
 {
+DeviceState *d = DEVICE(xhci);
 XHCIPort *port;
 int i, usbports, speedmask;
 
@@ -3281,7 +3288,7 @@ static void usb_xhci_init(XHCIState *xhci, DeviceState 
*dev)
 usbports = MAX(xhci-numports_2, xhci-numports_3);
 xhci-numports = xhci-numports_2 + xhci-numports_3;
 
-usb_bus_new(xhci-bus, xhci_bus_ops, xhci-pci_dev.qdev);
+usb_bus_new(xhci-bus, xhci_bus_ops, d);
 
 for (i = 0; i  usbports; i++) {
 speedmask = 0;
@@ -3313,14 +3320,14 @@ static int usb_xhci_initfn(struct PCIDevice *dev)
 {
 int i, ret;
 
-XHCIState *xhci = DO_UPCAST(XHCIState, pci_dev, dev);
+XHCIState *xhci = XHCI(dev);
 
 xhci-pci_dev.config[PCI_CLASS_PROG] = 0x30;/* xHCI */
 xhci-pci_dev.config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin 1 */
 xhci-pci_dev.config[PCI_CACHE_LINE_SIZE] = 0x10;
 xhci-pci_dev.config[0x60] = 0x30; /* release number */
 
-usb_xhci_init(xhci, dev-qdev);
+usb_xhci_init(xhci, DEVICE(dev));
 
 if (xhci-numintrs  MAXINTRS) {
 xhci-numintrs = MAXINTRS;
@@ -3581,7 +3588,7 @@ static void xhci_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo xhci_info = {
-.name  = nec-usb-xhci,
+.name  = TYPE_XHCI,
 .parent= TYPE_PCI_DEVICE,
 .instance_size = sizeof(XHCIState),
 .class_init= xhci_class_init,
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 05/30] scsi/lsi53c895a: QOM Upcast Sweep

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Define and use standard QOM cast macro. Remove usages of DO_UPCAST
and direct - style upcasting.

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/scsi/lsi53c895a.c | 26 --
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
index 22b8e98..d488c5c 100644
--- a/hw/scsi/lsi53c895a.c
+++ b/hw/scsi/lsi53c895a.c
@@ -275,6 +275,11 @@ typedef struct {
 uint32_t script_ram[2048];
 } LSIState;
 
+#define TYPE_LSI53C895A lsi53c895a
+
+#define LSI53C895A(obj) \
+OBJECT_CHECK(LSIState, (obj), TYPE_LSI53C895A)
+
 static inline int lsi_irq_on_rsl(LSIState *s)
 {
 return (s-sien0  LSI_SIST0_RSL)  (s-scid  LSI_SCID_RRE);
@@ -653,7 +658,7 @@ static void lsi_request_free(LSIState *s, lsi_request *p)
 
 static void lsi_request_cancelled(SCSIRequest *req)
 {
-LSIState *s = DO_UPCAST(LSIState, dev.qdev, req-bus-qbus.parent);
+LSIState *s = LSI53C895A(req-bus-qbus.parent);
 lsi_request *p = req-hba_private;
 
 req-hba_private = NULL;
@@ -692,7 +697,7 @@ static int lsi_queue_req(LSIState *s, SCSIRequest *req, 
uint32_t len)
  /* Callback to indicate that the SCSI layer has completed a command.  */
 static void lsi_command_complete(SCSIRequest *req, uint32_t status, size_t 
resid)
 {
-LSIState *s = DO_UPCAST(LSIState, dev.qdev, req-bus-qbus.parent);
+LSIState *s = LSI53C895A(req-bus-qbus.parent);
 int out;
 
 out = (s-sstat1  PHASE_MASK) == PHASE_DO;
@@ -717,7 +722,7 @@ static void lsi_command_complete(SCSIRequest *req, uint32_t 
status, size_t resid
  /* Callback to indicate that the SCSI layer has completed a transfer.  */
 static void lsi_transfer_data(SCSIRequest *req, uint32_t len)
 {
-LSIState *s = DO_UPCAST(LSIState, dev.qdev, req-bus-qbus.parent);
+LSIState *s = LSI53C895A(req-bus-qbus.parent);
 int out;
 
 assert(req-hba_private);
@@ -1726,7 +1731,7 @@ static void lsi_reg_writeb(LSIState *s, int offset, 
uint8_t val)
 lsi_execute_script(s);
 }
 if (val  LSI_ISTAT0_SRST) {
-qdev_reset_all(s-dev.qdev);
+qdev_reset_all(DEVICE(s));
 }
 break;
 case 0x16: /* MBOX0 */
@@ -1960,7 +1965,7 @@ static const MemoryRegionOps lsi_io_ops = {
 
 static void lsi_scsi_reset(DeviceState *dev)
 {
-LSIState *s = DO_UPCAST(LSIState, dev.qdev, dev);
+LSIState *s = LSI53C895A(dev);
 
 lsi_soft_reset(s);
 }
@@ -2061,7 +2066,7 @@ static const VMStateDescription vmstate_lsi_scsi = {
 
 static void lsi_scsi_uninit(PCIDevice *d)
 {
-LSIState *s = DO_UPCAST(LSIState, dev, d);
+LSIState *s = LSI53C895A(d);
 
 memory_region_destroy(s-mmio_io);
 memory_region_destroy(s-ram_io);
@@ -2080,7 +2085,8 @@ static const struct SCSIBusInfo lsi_scsi_info = {
 
 static int lsi_scsi_init(PCIDevice *dev)
 {
-LSIState *s = DO_UPCAST(LSIState, dev, dev);
+LSIState *s = LSI53C895A(dev);
+DeviceState *d = DEVICE(dev);
 uint8_t *pci_conf;
 
 pci_conf = s-dev.config;
@@ -2099,8 +2105,8 @@ static int lsi_scsi_init(PCIDevice *dev)
 pci_register_bar(s-dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, s-ram_io);
 QTAILQ_INIT(s-queue);
 
-scsi_bus_new(s-bus, dev-qdev, lsi_scsi_info, NULL);
-if (!dev-qdev.hotplugged) {
+scsi_bus_new(s-bus, d, lsi_scsi_info, NULL);
+if (!d-hotplugged) {
 return scsi_bus_legacy_handle_cmdline(s-bus);
 }
 return 0;
@@ -2122,7 +2128,7 @@ static void lsi_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo lsi_info = {
-.name  = lsi53c895a,
+.name  = TYPE_LSI53C895A,
 .parent= TYPE_PCI_DEVICE,
 .instance_size = sizeof(LSIState),
 .class_init= lsi_class_init,
-- 
1.8.3.rc1.44.gb387c77.dirty




Re: [Qemu-devel] [PATCH] qemu: piix: PCI bridge ACPI hotplug support

2013-06-11 Thread Michael S. Tsirkin
On Mon, Jun 10, 2013 at 08:25:15PM -0500, Anthony Liguori wrote:
  I do understand your desire to pass this stuff as parameters, but I
  really don't see it as feasible.  I'm hoping that if you can write up
  some examples with specifics you'll either enlighten me or you'll see
  the difficulties I'm trying to describe.
 
 Is your basic argument that generating these tables is hard, QEMU can
 and should just hard code them and change them whenever it feels like
 without involving SeaBIOS?

Basically I think it makes sense to listen to people
that write drivers for PV hardware that QEMU exposes.
bios is one such example.

If people that are supposed to use our interfaces
ask for a specific interface, I think we should listen.
If people come and say that building acpi dynamically is hard
for them and they want QEMU to prepare templates for acpi -
and there's overwhelming concensus on this -
QEMU should stop going tough luck we know what's best for you.

 If that's what it boils down to, I'll look more closely at it.

So please look at the original patchset
[PATCH RFC 00/13] qemu: generate acpi tables for the guest

and let's move the discussion of it beyond the meta-argument
QEMU does not need to generate any ACPI tables 
and to the specific interface that we can use
to make life easier for the bios.

Specifically several options were discussed, on and off-line for passing
per-formatted tables to firmware:

1. use existing fw cfg interface from bios,
   qemu side make it work well with cross version migration.
2. same as 1 but find some existing hardware that is similar
   to fw cfg and emulate it. For example build a directory
   structure in some flash.
3. make qemu put tables into guest memory.
   bios needs to reserve this memory.
4. same as 3 but bios allocates memory and
   passes address to qemu.

Kevin suggested 1. This is what my patchset implements.
But I think bios could live with any of
the others, as long as it's a generic interface so
we can stop changing bios code all the time.

-- 
MST



[Qemu-devel] [RFT PATCH v1 06/30] scsi/megasas: QOM Upcast Sweep

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Define and use standard QOM cast macro. Remove usages of DO_UPCAST
and direct - style upcasting.

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/scsi/megasas.c | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index fe6550c..21eaf4f 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -108,6 +108,11 @@ typedef struct MegasasState {
 SCSIBus bus;
 } MegasasState;
 
+#define TYPE_MEGASAS megasas
+
+#define MEGASAS(obj) \
+OBJECT_CHECK(MegasasState, (obj), TYPE_MEGASAS)
+
 #define MEGASAS_INTR_DISABLED_MASK 0x
 
 static bool megasas_intr_enabled(MegasasState *s)
@@ -2039,13 +2044,13 @@ static void megasas_soft_reset(MegasasState *s)
 
 static void megasas_scsi_reset(DeviceState *dev)
 {
-MegasasState *s = DO_UPCAST(MegasasState, dev.qdev, dev);
+MegasasState *s = MEGASAS(dev);
 
 megasas_soft_reset(s);
 }
 
 static const VMStateDescription vmstate_megasas = {
-.name = megasas,
+.name = TYPE_MEGASAS,
 .version_id = 0,
 .minimum_version_id = 0,
 .minimum_version_id_old = 0,
@@ -2064,7 +2069,7 @@ static const VMStateDescription vmstate_megasas = {
 
 static void megasas_scsi_uninit(PCIDevice *d)
 {
-MegasasState *s = DO_UPCAST(MegasasState, dev, d);
+MegasasState *s = MEGASAS(d);
 
 #ifdef USE_MSIX
 msix_uninit(s-dev, s-mmio_io);
@@ -2087,7 +2092,7 @@ static const struct SCSIBusInfo megasas_scsi_info = {
 
 static int megasas_scsi_init(PCIDevice *dev)
 {
-MegasasState *s = DO_UPCAST(MegasasState, dev, dev);
+MegasasState *s = MEGASAS(dev);
 uint8_t *pci_conf;
 int i, bar_type;
 
@@ -2158,7 +2163,7 @@ static int megasas_scsi_init(PCIDevice *dev)
 s-frames[i].state = s;
 }
 
-scsi_bus_new(s-bus, dev-qdev, megasas_scsi_info, NULL);
+scsi_bus_new(s-bus, DEVICE(dev), megasas_scsi_info, NULL);
 scsi_bus_legacy_handle_cmdline(s-bus);
 return 0;
 }
@@ -2198,7 +2203,7 @@ static void megasas_class_init(ObjectClass *oc, void 
*data)
 }
 
 static const TypeInfo megasas_info = {
-.name  = megasas,
+.name  = TYPE_MEGASAS,
 .parent = TYPE_PCI_DEVICE,
 .instance_size = sizeof(MegasasState),
 .class_init = megasas_class_init,
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 07/30] scsi/esp-pci: QOM Upcast Sweep

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Define and use standard QOM cast macro. Remove usages of DO_UPCAST
and direct - style upcasting.

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/scsi/esp-pci.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
index 029789a..2a72da6 100644
--- a/hw/scsi/esp-pci.c
+++ b/hw/scsi/esp-pci.c
@@ -31,6 +31,9 @@
 
 #define TYPE_AM53C974_DEVICE am53c974
 
+#define PCI_ESP(obj) \
+OBJECT_CHECK(PCIESPState, (obj), TYPE_AM53C974_DEVICE)
+
 #define DMA_CMD   0x0
 #define DMA_STC   0x1
 #define DMA_SPA   0x2
@@ -288,7 +291,7 @@ static const MemoryRegionOps esp_pci_io_ops = {
 
 static void esp_pci_hard_reset(DeviceState *dev)
 {
-PCIESPState *pci = DO_UPCAST(PCIESPState, dev.qdev, dev);
+PCIESPState *pci = PCI_ESP(dev);
 esp_hard_reset(pci-esp);
 pci-dma_regs[DMA_CMD] = ~(DMA_CMD_DIR | DMA_CMD_INTE_D | DMA_CMD_INTE_P
   | DMA_CMD_MDL | DMA_CMD_DIAG | DMA_CMD_MASK);
@@ -336,7 +339,8 @@ static const struct SCSIBusInfo esp_pci_scsi_info = {
 
 static int esp_pci_scsi_init(PCIDevice *dev)
 {
-PCIESPState *pci = DO_UPCAST(PCIESPState, dev, dev);
+PCIESPState *pci = PCI_ESP(dev);
+DeviceState *d = DEVICE(dev);
 ESPState *s = pci-esp;
 uint8_t *pci_conf;
 
@@ -354,8 +358,8 @@ static int esp_pci_scsi_init(PCIDevice *dev)
 pci_register_bar(pci-dev, 0, PCI_BASE_ADDRESS_SPACE_IO, pci-io);
 s-irq = pci-dev.irq[0];
 
-scsi_bus_new(s-bus, dev-qdev, esp_pci_scsi_info, NULL);
-if (!dev-qdev.hotplugged) {
+scsi_bus_new(s-bus, d, esp_pci_scsi_info, NULL);
+if (!d-hotplugged) {
 return scsi_bus_legacy_handle_cmdline(s-bus);
 }
 return 0;
@@ -363,7 +367,7 @@ static int esp_pci_scsi_init(PCIDevice *dev)
 
 static void esp_pci_scsi_uninit(PCIDevice *d)
 {
-PCIESPState *pci = DO_UPCAST(PCIESPState, dev, d);
+PCIESPState *pci = PCI_ESP(d);
 
 memory_region_destroy(pci-io);
 }
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 08/30] ide/ich: QOM Upcast Sweep

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Define and use standard QOM cast macro. Remove usages of DO_UPCAST
and direct - style upcasting.

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/ide/ahci.h |  5 +
 hw/ide/ich.c  | 10 +-
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/hw/ide/ahci.h b/hw/ide/ahci.h
index 85f37fe..37b85e5 100644
--- a/hw/ide/ahci.h
+++ b/hw/ide/ahci.h
@@ -305,6 +305,11 @@ typedef struct AHCIPCIState {
 AHCIState ahci;
 } AHCIPCIState;
 
+#define TYPE_ICH_AHCI ich9-ahci
+
+#define ICH_AHCI(obj) \
+OBJECT_CHECK(AHCIPCIState, (obj), TYPE_ICH_AHCI)
+
 extern const VMStateDescription vmstate_ahci;
 
 #define VMSTATE_AHCI(_field, _state) {   \
diff --git a/hw/ide/ich.c b/hw/ide/ich.c
index ed1f1a2..8b59988 100644
--- a/hw/ide/ich.c
+++ b/hw/ide/ich.c
@@ -92,7 +92,7 @@ static const VMStateDescription vmstate_ich9_ahci = {
 
 static void pci_ich9_reset(DeviceState *dev)
 {
-struct AHCIPCIState *d = DO_UPCAST(struct AHCIPCIState, card.qdev, dev);
+struct AHCIPCIState *d = ICH_AHCI(dev);
 
 ahci_reset(d-ahci);
 }
@@ -102,9 +102,9 @@ static int pci_ich9_ahci_init(PCIDevice *dev)
 struct AHCIPCIState *d;
 int sata_cap_offset;
 uint8_t *sata_cap;
-d = DO_UPCAST(struct AHCIPCIState, card, dev);
+d = ICH_AHCI(dev);
 
-ahci_init(d-ahci, dev-qdev, pci_dma_context(dev), 6);
+ahci_init(d-ahci, DEVICE(dev), pci_dma_context(dev), 6);
 
 pci_config_set_prog_interface(d-card.config, AHCI_PROGMODE_MAJOR_REV_1);
 
@@ -141,7 +141,7 @@ static int pci_ich9_ahci_init(PCIDevice *dev)
 static void pci_ich9_uninit(PCIDevice *dev)
 {
 struct AHCIPCIState *d;
-d = DO_UPCAST(struct AHCIPCIState, card, dev);
+d = ICH_AHCI(dev);
 
 msi_uninit(dev);
 ahci_uninit(d-ahci);
@@ -163,7 +163,7 @@ static void ich_ahci_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo ich_ahci_info = {
-.name  = ich9-ahci,
+.name  = TYPE_ICH_AHCI,
 .parent= TYPE_PCI_DEVICE,
 .instance_size = sizeof(AHCIPCIState),
 .class_init= ich_ahci_class_init,
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 09/30] ide/piix: QOM casting sweep

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Use standard QOM cast macro. Remove usage of DO_UPCAST and
direct - style upcasting.

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/ide/piix.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/ide/piix.c b/hw/ide/piix.c
index bf2856f..d0fdea3 100644
--- a/hw/ide/piix.c
+++ b/hw/ide/piix.c
@@ -135,7 +135,7 @@ static void pci_piix_init_ports(PCIIDEState *d) {
 int i;
 
 for (i = 0; i  2; i++) {
-ide_bus_new(d-bus[i], d-dev.qdev, i, 2);
+ide_bus_new(d-bus[i], DEVICE(d), i, 2);
 ide_init_ioport(d-bus[i], NULL, port_info[i].iobase,
 port_info[i].iobase2);
 ide_init2(d-bus[i], isa_get_irq(NULL, port_info[i].isairq));
@@ -159,7 +159,7 @@ static int pci_piix_ide_initfn(PCIDevice *dev)
 bmdma_setup_bar(d);
 pci_register_bar(d-dev, 4, PCI_BASE_ADDRESS_SPACE_IO, d-bmdma_bar);
 
-vmstate_register(d-dev.qdev, 0, vmstate_ide_pci, d);
+vmstate_register(DEVICE(dev), 0, vmstate_ide_pci, d);
 
 pci_piix_init_ports(d);
 
@@ -173,7 +173,7 @@ static int pci_piix3_xen_ide_unplug(DeviceState *dev)
 DriveInfo *di;
 int i = 0;
 
-pci_dev = DO_UPCAST(PCIDevice, qdev, dev);
+pci_dev = PCI_DEVICE(dev);
 pci_ide = DO_UPCAST(PCIIDEState, dev, pci_dev);
 
 for (; i  3; i++) {
@@ -188,7 +188,7 @@ static int pci_piix3_xen_ide_unplug(DeviceState *dev)
 drive_put_ref(di);
 }
 }
-qdev_reset_all((pci_ide-dev.qdev));
+qdev_reset_all(DEVICE(dev));
 return 0;
 }
 
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 10/30] acpi/piix4: QOM Upcast Sweep

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Use standard QOM cast macro. Remove usages of DO_UPCAST
and direct - style upcasting.

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/acpi/piix4.c | 31 +--
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index e6525ac..83a8407 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -96,6 +96,11 @@ typedef struct PIIX4PMState {
 Notifier cpu_added_notifier;
 } PIIX4PMState;
 
+#define TYPE_PIIX4_PM PIIX4_PM
+
+#define PIIX4_PM(obj) \
+OBJECT_CHECK(PIIX4PMState, (obj), TYPE_PIIX4_PM)
+
 static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
PCIBus *bus, PIIX4PMState *s);
 
@@ -300,7 +305,7 @@ static const VMStateDescription vmstate_acpi = {
 static void acpi_piix_eject_slot(PIIX4PMState *s, unsigned slots)
 {
 BusChild *kid, *next;
-BusState *bus = qdev_get_parent_bus(s-dev.qdev);
+BusState *bus = qdev_get_parent_bus(DEVICE(s));
 int slot = ffs(slots) - 1;
 bool slot_free = true;
 
@@ -326,8 +331,7 @@ static void acpi_piix_eject_slot(PIIX4PMState *s, unsigned 
slots)
 
 static void piix4_update_hotplug(PIIX4PMState *s)
 {
-PCIDevice *dev = s-dev;
-BusState *bus = qdev_get_parent_bus(dev-qdev);
+BusState *bus = qdev_get_parent_bus(DEVICE(s));
 BusChild *kid, *next;
 
 /* Execute any pending removes during reset */
@@ -395,7 +399,7 @@ static void piix4_pm_machine_ready(Notifier *n, void 
*opaque)
 
 static int piix4_pm_initfn(PCIDevice *dev)
 {
-PIIX4PMState *s = DO_UPCAST(PIIX4PMState, dev, dev);
+PIIX4PMState *s = PIIX4_PM(dev);
 uint8_t *pci_conf;
 
 pci_conf = s-dev.config;
@@ -418,7 +422,7 @@ static int piix4_pm_initfn(PCIDevice *dev)
 pci_conf[0x90] = s-smb_io_base | 1;
 pci_conf[0x91] = s-smb_io_base  8;
 pci_conf[0xd2] = 0x09;
-pm_smbus_init(s-dev.qdev, s-smb);
+pm_smbus_init(DEVICE(dev), s-smb);
 memory_region_set_enabled(s-smb.io, pci_conf[0xd2]  1);
 memory_region_add_subregion(pci_address_space_io(dev),
 s-smb_io_base, s-smb.io);
@@ -449,18 +453,18 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t 
smb_io_base,
qemu_irq sci_irq, qemu_irq smi_irq,
int kvm_enabled, FWCfgState *fw_cfg)
 {
-PCIDevice *dev;
+DeviceState *dev;
 PIIX4PMState *s;
 
-dev = pci_create(bus, devfn, PIIX4_PM);
-qdev_prop_set_uint32(dev-qdev, smb_io_base, smb_io_base);
+dev = DEVICE(pci_create(bus, devfn, TYPE_PIIX4_PM));
+qdev_prop_set_uint32(dev, smb_io_base, smb_io_base);
 
-s = DO_UPCAST(PIIX4PMState, dev, dev);
+s = PIIX4_PM(dev);
 s-irq = sci_irq;
 s-smi_irq = smi_irq;
 s-kvm_enabled = kvm_enabled;
 
-qdev_init_nofail(dev-qdev);
+qdev_init_nofail(dev);
 
 if (fw_cfg) {
 uint8_t suspend[6] = {128, 0, 0, 129, 128, 128};
@@ -500,7 +504,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo piix4_pm_info = {
-.name  = PIIX4_PM,
+.name  = TYPE_PIIX4_PM,
 .parent= TYPE_PCI_DEVICE,
 .instance_size = sizeof(PIIX4PMState),
 .class_init= piix4_pm_class_init,
@@ -678,7 +682,7 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion 
*parent,
   PCI_HOTPLUG_SIZE);
 memory_region_add_subregion(parent, PCI_HOTPLUG_ADDR,
 s-io_pci);
-pci_bus_hotplug(bus, piix4_device_hotplug, s-dev.qdev);
+pci_bus_hotplug(bus, piix4_device_hotplug, DEVICE(s));
 
 qemu_for_each_cpu(piix4_init_cpu_status, s-gpe_cpu);
 memory_region_init_io(s-io_cpu, cpu_hotplug_ops, s, apci-cpu-hotplug,
@@ -704,8 +708,7 @@ static int piix4_device_hotplug(DeviceState *qdev, 
PCIDevice *dev,
PCIHotplugState state)
 {
 int slot = PCI_SLOT(dev-devfn);
-PIIX4PMState *s = DO_UPCAST(PIIX4PMState, dev,
-PCI_DEVICE(qdev));
+PIIX4PMState *s = PIIX4_PM(qdev);
 
 /* Don't send event when device is enabled during qemu machine creation:
  * it is present on boot, no hotplug event is necessary. We do send an
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 11/30] misc/pci-testdev: QOM Upcast Sweep

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Define and use standard QOM cast macro. Remove usages of DO_UPCAST
and direct - style upcasting.

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/misc/pci-testdev.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/hw/misc/pci-testdev.c b/hw/misc/pci-testdev.c
index 71ce5a3..add58b7 100644
--- a/hw/misc/pci-testdev.c
+++ b/hw/misc/pci-testdev.c
@@ -83,6 +83,11 @@ typedef struct PCITestDevState {
 int current;
 } PCITestDevState;
 
+#define TYPE_PCI_TEST_DEV pci-testdev
+
+#define PCI_TEST_DEV(obj) \
+OBJECT_CHECK(PCITestDevState, (obj), TYPE_PCI_TEST_DEV)
+
 #define IOTEST_IS_MEM(i) (strcmp(IOTEST_TYPE(i), portio))
 #define IOTEST_REGION(d, i) (IOTEST_IS_MEM(i) ?  (d)-mmio : (d)-portio)
 #define IOTEST_SIZE(i) (IOTEST_IS_MEM(i) ? IOTEST_MEMSIZE : IOTEST_IOSIZE)
@@ -274,7 +279,7 @@ static int pci_testdev_init(PCIDevice *pci_dev)
 static void
 pci_testdev_uninit(PCIDevice *dev)
 {
-PCITestDevState *d = DO_UPCAST(PCITestDevState, dev, dev);
+PCITestDevState *d = PCI_TEST_DEV(dev);
 int i;
 
 pci_testdev_reset(d);
@@ -291,7 +296,7 @@ pci_testdev_uninit(PCIDevice *dev)
 
 static void qdev_pci_testdev_reset(DeviceState *dev)
 {
-PCITestDevState *d = DO_UPCAST(PCITestDevState, dev.qdev, dev);
+PCITestDevState *d = PCI_TEST_DEV(dev);
 pci_testdev_reset(d);
 }
 
@@ -311,7 +316,7 @@ static void pci_testdev_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo pci_testdev_info = {
-.name  = pci-testdev,
+.name  = TYPE_PCI_TEST_DEV,
 .parent= TYPE_PCI_DEVICE,
 .instance_size = sizeof(PCITestDevState),
 .class_init= pci_testdev_class_init,
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 12/30] virtio/virtio-pci: QOM casting sweep

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Use standard QOM cast macro. Remove usages of container_of() and
direct - style upcasting.

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/virtio/virtio-pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 444b71a..a6cad0d 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -98,7 +98,7 @@ static void virtio_pci_bus_new(VirtioBusState *bus, 
VirtIOPCIProxy *dev);
 /* DeviceState to VirtIOPCIProxy. For use off data-path. TODO: use QOM. */
 static inline VirtIOPCIProxy *to_virtio_pci_proxy(DeviceState *d)
 {
-return container_of(d, VirtIOPCIProxy, pci_dev.qdev);
+return VIRTIO_PCI(d);
 }
 
 /* DeviceState to VirtIOPCIProxy. Note: used on datapath,
@@ -106,7 +106,7 @@ static inline VirtIOPCIProxy 
*to_virtio_pci_proxy(DeviceState *d)
  */
 static inline VirtIOPCIProxy *to_virtio_pci_proxy_fast(DeviceState *d)
 {
-return container_of(d, VirtIOPCIProxy, pci_dev.qdev);
+return VIRTIO_PCI(d);
 }
 
 static void virtio_pci_notify(DeviceState *d, uint16_t vector)
-- 
1.8.3.rc1.44.gb387c77.dirty




Re: [Qemu-devel] [PATCH] qemu: piix: PCI bridge ACPI hotplug support

2013-06-11 Thread Michael S. Tsirkin
On Tue, Jun 11, 2013 at 07:33:02AM +0200, Gerd Hoffmann wrote:
   Hi,
 
 * Use of glib's GArray makes it much easier to build
   up tables in code without need for iasl and code patching
 
 Nice.
 
  Design:
  - each bus gets assigned a number 0-255
  - generated ACPI code writes this number
to a new BSEL register, then uses existing
UP/DOWN registers to probe slot status;
to eject, write number to BSEL register,
then slot into existing EJ
  
  This is to address the ACPI spec requirement to
  avoid config cycle access to any bus except PCI roots.
  
  Portability:
  - Non x86 (or any Linux) platforms don't need any of this code.
They can keep happily using SHPC the way
they always did.
 
 Hmm.  Is is possible to write a SHPC driver in AML?  I think it would be
 alot better to have one guest/host interface for pci bridge hotplug
 instead of two.
 
 cheers,
   Gerd

No, it's not possible, SHPC is not designed to be used from ACPI.

Two reasons off the top of my head, there are likely others:

1. SHPC uses regular PCI interrupts to signal events. It does not signal
   GFE and SCI.

2. SHPC uses config accesses to get information from device.
   ACPI does not allow config access anywhere except the root bus from ACPI
   (This requirement is designed to give the OS freedom
   to reconfigure PCI in an arbitrary way).

-- 
MST



Re: [Qemu-devel] [PATCH qom-cpu 47/59] spapr: Abstract spapr_fix_cpu_dt() with qemu_for_each_cpu()

2013-06-11 Thread David Gibson
On Sun, Jun 09, 2013 at 09:13:14PM +0200, Andreas Färber wrote:
 Signed-off-by: Andreas Färber afaer...@suse.de

These days, spapr patches should be CCed to Alexey, instead of me.
Though, fwiw,

Reviewed-by: David Gibson da...@gibson.dropbear.id.au

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


pgpbX09Eko0ra.pgp
Description: PGP signature


[Qemu-devel] [RFT PATCH v1 13/30] virtio/vmware_vga: QOM casting sweep

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Define and use standard QOM cast macro. Remove usages of DO_UPCAST and
direct - style casting.

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/display/vmware_vga.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
index fd3569d..0e2aa3f 100644
--- a/hw/display/vmware_vga.c
+++ b/hw/display/vmware_vga.c
@@ -81,6 +81,11 @@ struct vmsvga_state_s {
 int redraw_fifo_first, redraw_fifo_last;
 };
 
+#define TYPE_VM_SVGA vmware-svga
+
+#define VM_SVGA(obj) \
+OBJECT_CHECK(struct pci_vmsvga_state_s, (obj), TYPE_VM_SVGA)
+
 struct pci_vmsvga_state_s {
 PCIDevice card;
 struct vmsvga_state_s chip;
@@ -1092,8 +1097,7 @@ static void vmsvga_update_display(void *opaque)
 
 static void vmsvga_reset(DeviceState *dev)
 {
-struct pci_vmsvga_state_s *pci =
-DO_UPCAST(struct pci_vmsvga_state_s, card.qdev, dev);
+struct pci_vmsvga_state_s *pci = VM_SVGA(dev);
 struct vmsvga_state_s *s = pci-chip;
 
 s-index = 0;
@@ -1246,8 +1250,7 @@ static const MemoryRegionOps vmsvga_io_ops = {
 
 static int pci_vmsvga_initfn(PCIDevice *dev)
 {
-struct pci_vmsvga_state_s *s =
-DO_UPCAST(struct pci_vmsvga_state_s, card, dev);
+struct pci_vmsvga_state_s *s = VM_SVGA(dev);
 
 s-card.config[PCI_CACHE_LINE_SIZE] = 0x08; /* Cache line size */
 s-card.config[PCI_LATENCY_TIMER] = 0x40;   /* Latency timer */
@@ -1299,7 +1302,7 @@ static void vmsvga_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo vmsvga_info = {
-.name  = vmware-svga,
+.name  = TYPE_VM_SVGA,
 .parent= TYPE_PCI_DEVICE,
 .instance_size = sizeof(struct pci_vmsvga_state_s),
 .class_init= vmsvga_class_init,
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 15/30] xen/xen_platform: QOM casting sweep

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Define and use standard QOM cast macro. Remove usages of DO_UPCAST
and direct - style upcasting.

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/xen/xen_platform.c | 28 
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/hw/xen/xen_platform.c b/hw/xen/xen_platform.c
index b6c6793..f119c44 100644
--- a/hw/xen/xen_platform.c
+++ b/hw/xen/xen_platform.c
@@ -62,6 +62,10 @@ typedef struct PCIXenPlatformState {
 int log_buffer_off;
 } PCIXenPlatformState;
 
+#define TYPE_XEN_PLATFORM xen-platform
+#define XEN_PLATFORM(obj) \
+OBJECT_CHECK(PCIXenPlatformState, (obj), TYPE_XEN_PLATFORM)
+
 #define XEN_PLATFORM_IOPORT 0x10
 
 /* Send bytes to syslog */
@@ -88,7 +92,7 @@ static void unplug_nic(PCIBus *b, PCIDevice *d, void *o)
 if (pci_get_word(d-config + PCI_CLASS_DEVICE) ==
 PCI_CLASS_NETWORK_ETHERNET
  strcmp(d-name, xen-pci-passthrough) != 0) {
-qdev_free(d-qdev);
+qdev_free(DEVICE(d));
 }
 }
 
@@ -103,7 +107,7 @@ static void unplug_disks(PCIBus *b, PCIDevice *d, void *o)
 if (pci_get_word(d-config + PCI_CLASS_DEVICE) ==
 PCI_CLASS_STORAGE_IDE
  strcmp(d-name, xen-pci-passthrough) != 0) {
-qdev_unplug((d-qdev), NULL);
+qdev_unplug(DEVICE(d), NULL);
 }
 }
 
@@ -114,7 +118,7 @@ static void pci_unplug_disks(PCIBus *bus)
 
 static void platform_fixed_ioport_writew(void *opaque, uint32_t addr, uint32_t 
val)
 {
-PCIXenPlatformState *s = opaque;
+PCIXenPlatformState *s = XEN_PLATFORM(opaque);
 
 switch (addr) {
 case 0:
@@ -164,7 +168,7 @@ static void platform_fixed_ioport_writel(void *opaque, 
uint32_t addr,
 
 static void platform_fixed_ioport_writeb(void *opaque, uint32_t addr, uint32_t 
val)
 {
-PCIXenPlatformState *s = opaque;
+PCIXenPlatformState *s = XEN_PLATFORM(opaque);
 
 switch (addr) {
 case 0: /* Platform flags */ {
@@ -187,7 +191,7 @@ static void platform_fixed_ioport_writeb(void *opaque, 
uint32_t addr, uint32_t v
 
 static uint32_t platform_fixed_ioport_readw(void *opaque, uint32_t addr)
 {
-PCIXenPlatformState *s = opaque;
+PCIXenPlatformState *s = XEN_PLATFORM(opaque);
 
 switch (addr) {
 case 0:
@@ -206,7 +210,7 @@ static uint32_t platform_fixed_ioport_readw(void *opaque, 
uint32_t addr)
 
 static uint32_t platform_fixed_ioport_readb(void *opaque, uint32_t addr)
 {
-PCIXenPlatformState *s = opaque;
+PCIXenPlatformState *s = XEN_PLATFORM(opaque);
 
 switch (addr) {
 case 0:
@@ -222,7 +226,7 @@ static uint32_t platform_fixed_ioport_readb(void *opaque, 
uint32_t addr)
 
 static void platform_fixed_ioport_reset(void *opaque)
 {
-PCIXenPlatformState *s = opaque;
+PCIXenPlatformState *s = XEN_PLATFORM(opaque);
 
 platform_fixed_ioport_writeb(s, 0, 0);
 }
@@ -292,7 +296,7 @@ static uint64_t xen_platform_ioport_readb(void *opaque, 
hwaddr addr,
 static void xen_platform_ioport_writeb(void *opaque, hwaddr addr,
uint64_t val, unsigned int size)
 {
-PCIXenPlatformState *s = opaque;
+PCIXenPlatformState *s = XEN_PLATFORM(opaque);
 
 switch (addr) {
 case 0: /* Platform flags */
@@ -349,7 +353,7 @@ static void platform_mmio_setup(PCIXenPlatformState *d)
 
 static int xen_platform_post_load(void *opaque, int version_id)
 {
-PCIXenPlatformState *s = opaque;
+PCIXenPlatformState *s = XEN_PLATFORM(opaque);
 
 platform_fixed_ioport_writeb(s, 0, s-flags);
 
@@ -371,7 +375,7 @@ static const VMStateDescription vmstate_xen_platform = {
 
 static int xen_platform_initfn(PCIDevice *dev)
 {
-PCIXenPlatformState *d = DO_UPCAST(PCIXenPlatformState, pci_dev, dev);
+PCIXenPlatformState *d = XEN_PLATFORM(dev);
 uint8_t *pci_conf;
 
 pci_conf = d-pci_dev.config;
@@ -397,7 +401,7 @@ static int xen_platform_initfn(PCIDevice *dev)
 
 static void platform_reset(DeviceState *dev)
 {
-PCIXenPlatformState *s = DO_UPCAST(PCIXenPlatformState, pci_dev.qdev, dev);
+PCIXenPlatformState *s = XEN_PLATFORM(dev);
 
 platform_fixed_ioport_reset(s);
 }
@@ -420,7 +424,7 @@ static void xen_platform_class_init(ObjectClass *klass, 
void *data)
 }
 
 static const TypeInfo xen_platform_info = {
-.name  = xen-platform,
+.name  = TYPE_XEN_PLATFORM,
 .parent= TYPE_PCI_DEVICE,
 .instance_size = sizeof(PCIXenPlatformState),
 .class_init= xen_platform_class_init,
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 16/30] isa/*: QOM casting sweep

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Use standard QOM cast macros. Remove usage of DO_UPCAST and
direct - style upcasting.

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/isa/i82378.c   |  8 
 hw/isa/lpc_ich9.c |  6 +++---
 hw/isa/piix4.c|  4 ++--
 hw/isa/vt82c686.c | 14 +++---
 4 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/hw/isa/i82378.c b/hw/isa/i82378.c
index cced9af..95a2d1c 100644
--- a/hw/isa/i82378.c
+++ b/hw/isa/i82378.c
@@ -159,8 +159,7 @@ static void i82378_request_out0_irq(void *opaque, int irq, 
int level)
 
 static void i82378_request_pic_irq(void *opaque, int irq, int level)
 {
-DeviceState *dev = opaque;
-PCIDevice *pci = DO_UPCAST(PCIDevice, qdev, dev);
+PCIDevice *pci = PCI_DEVICE(opaque);
 PCIi82378State *s = DO_UPCAST(PCIi82378State, pci_dev, pci);
 
 qemu_set_irq(s-state.i8259[irq], level);
@@ -210,6 +209,7 @@ static void i82378_init(DeviceState *dev, I82378State *s)
 static int pci_i82378_init(PCIDevice *dev)
 {
 PCIi82378State *pci = DO_UPCAST(PCIi82378State, pci_dev, dev);
+DeviceState *d = DEVICE(pci);
 I82378State *s = pci-state;
 uint8_t *pci_conf;
 
@@ -233,9 +233,9 @@ static int pci_i82378_init(PCIDevice *dev)
 pci_set_long(pci_conf + PCI_BASE_ADDRESS_0, pci-isa_io_base);
 
 isa_mem_base = pci-isa_mem_base;
-isa_bus_new(dev-qdev, pci_address_space_io(dev));
+isa_bus_new(d, pci_address_space_io(dev));
 
-i82378_init(dev-qdev, s);
+i82378_init(d, s);
 
 return 0;
 }
diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index 667e882..497ced1 100644
--- a/hw/isa/lpc_ich9.c
+++ b/hw/isa/lpc_ich9.c
@@ -277,7 +277,7 @@ void ich9_lpc_set_irq(void *opaque, int pirq, int level)
  */
 int ich9_lpc_map_irq(PCIDevice *pci_dev, int intx)
 {
-BusState *bus = qdev_get_parent_bus(pci_dev-qdev);
+BusState *bus = qdev_get_parent_bus(DEVICE(pci_dev));
 PCIBus *pci_bus = PCI_BUS(bus);
 PCIDevice *lpc_pdev =
 pci_bus-devices[PCI_DEVFN(ICH9_LPC_DEV, ICH9_LPC_FUNC)];
@@ -364,7 +364,7 @@ void ich9_lpc_pm_init(PCIDevice *lpc_pci)
 sci_irq = qemu_allocate_irqs(ich9_set_sci, lpc, 1);
 ich9_pm_init(lpc_pci, lpc-pm, sci_irq[0]);
 
-ich9_lpc_reset(lpc-d.qdev);
+ich9_lpc_reset(DEVICE(lpc));
 }
 
 /* APM */
@@ -529,7 +529,7 @@ static int ich9_lpc_initfn(PCIDevice *d)
 ICH9LPCState *lpc = ICH9_LPC_DEVICE(d);
 ISABus *isa_bus;
 
-isa_bus = isa_bus_new(d-qdev, get_system_io());
+isa_bus = isa_bus_new(DEVICE(d), get_system_io());
 
 pci_set_long(d-wmask + ICH9_LPC_PMBASE,
  ICH9_LPC_PMBASE_BASE_ADDRESS_MASK);
diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
index d750413..1eb05b2 100644
--- a/hw/isa/piix4.c
+++ b/hw/isa/piix4.c
@@ -87,7 +87,7 @@ static int piix4_initfn(PCIDevice *dev)
 {
 PIIX4State *d = DO_UPCAST(PIIX4State, dev, dev);
 
-isa_bus_new(d-dev.qdev, pci_address_space_io(dev));
+isa_bus_new(DEVICE(dev), pci_address_space_io(dev));
 piix4_dev = d-dev;
 qemu_register_reset(piix4_reset, d);
 return 0;
@@ -98,7 +98,7 @@ int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn)
 PCIDevice *d;
 
 d = pci_create_simple_multifunction(bus, devfn, true, PIIX4);
-*isa_bus = DO_UPCAST(ISABus, qbus, qdev_get_child_bus(d-qdev, isa.0));
+*isa_bus = DO_UPCAST(ISABus, qbus, qdev_get_child_bus(DEVICE(d), isa.0));
 return d-devfn;
 }
 
diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index 5261927..8ec0d84 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -266,7 +266,7 @@ void vt82c686b_ac97_init(PCIBus *bus, int devfn)
 PCIDevice *dev;
 
 dev = pci_create(bus, devfn, VT82C686B_AC97);
-qdev_init_nofail(dev-qdev);
+qdev_init_nofail(DEVICE(dev));
 }
 
 static void via_ac97_class_init(ObjectClass *klass, void *data)
@@ -307,7 +307,7 @@ void vt82c686b_mc97_init(PCIBus *bus, int devfn)
 PCIDevice *dev;
 
 dev = pci_create(bus, devfn, VT82C686B_MC97);
-qdev_init_nofail(dev-qdev);
+qdev_init_nofail(DEVICE(dev));
 }
 
 static void via_mc97_class_init(ObjectClass *klass, void *data)
@@ -349,7 +349,7 @@ static int vt82c686b_pm_initfn(PCIDevice *dev)
 pci_conf[0x90] = s-smb_io_base | 1;
 pci_conf[0x91] = s-smb_io_base  8;
 pci_conf[0xd2] = 0x90;
-pm_smbus_init(s-dev.qdev, s-smb);
+pm_smbus_init(DEVICE(dev), s-smb);
 memory_region_add_subregion(get_system_io(), s-smb_io_base, s-smb.io);
 
 apm_init(dev, s-apm, NULL, s);
@@ -372,11 +372,11 @@ i2c_bus *vt82c686b_pm_init(PCIBus *bus, int devfn, 
uint32_t smb_io_base,
 VT686PMState *s;
 
 dev = pci_create(bus, devfn, VT82C686B_PM);
-qdev_prop_set_uint32(dev-qdev, smb_io_base, smb_io_base);
+qdev_prop_set_uint32(DEVICE(dev), smb_io_base, smb_io_base);
 
 s = DO_UPCAST(VT686PMState, dev, dev);
 
-qdev_init_nofail(dev-qdev);
+qdev_init_nofail(DEVICE(dev));
 
 return s-smb.smbus;
 }
@@ -427,7 +427,7 @@ static int 

[Qemu-devel] [RFT PATCH v1 14/30] misc/ivshmem: QOM Upcast Sweep

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Define and use standard QOM cast macro. Remove usages of DO_UPCAST
and direct - style upcasting.

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/misc/ivshmem.c | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index a19a6d6..000556a 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -48,6 +48,10 @@
 #define IVSHMEM_DPRINTF(fmt, ...)
 #endif
 
+#define TYPE_IVSHMEM ivshmem
+#define IVSHMEM(obj) \
+OBJECT_CHECK(IVShmemState, (obj), TYPE_IVSHMEM)
+
 typedef struct Peer {
 int nb_eventfds;
 EventNotifier *eventfds;
@@ -341,7 +345,7 @@ static void create_shared_memory_BAR(IVShmemState *s, int 
fd) {
 
 memory_region_init_ram_ptr(s-ivshmem, ivshmem.bar2,
s-ivshmem_size, ptr);
-vmstate_register_ram(s-ivshmem, s-dev.qdev);
+vmstate_register_ram(s-ivshmem, DEVICE(s-dev));
 memory_region_add_subregion(s-bar, 0, s-ivshmem);
 
 /* region for shared memory */
@@ -469,7 +473,7 @@ static void ivshmem_read(void *opaque, const uint8_t * buf, 
int flags)
 incoming_fd, 0);
 memory_region_init_ram_ptr(s-ivshmem,
ivshmem.bar2, s-ivshmem_size, map_ptr);
-vmstate_register_ram(s-ivshmem, s-dev.qdev);
+vmstate_register_ram(s-ivshmem, DEVICE(s-dev));
 
 IVSHMEM_DPRINTF(guest h/w addr = % PRIu64 , size = % PRIu64 \n,
  s-ivshmem_offset, s-ivshmem_size);
@@ -534,7 +538,7 @@ static void ivshmem_use_msix(IVShmemState * s)
 
 static void ivshmem_reset(DeviceState *d)
 {
-IVShmemState *s = DO_UPCAST(IVShmemState, dev.qdev, d);
+IVShmemState *s = IVSHMEM(d);
 
 s-intrstatus = 0;
 ivshmem_use_msix(s);
@@ -648,7 +652,7 @@ static int pci_ivshmem_init(PCIDevice *dev)
 s-ivshmem_size = ivshmem_get_size(s);
 }
 
-register_savevm(s-dev.qdev, ivshmem, 0, 0, ivshmem_save, ivshmem_load,
+register_savevm(DEVICE(dev), ivshmem, 0, 0, ivshmem_save, ivshmem_load,
 dev);
 
 /* IRQFD requires MSI */
@@ -779,10 +783,10 @@ static void pci_ivshmem_uninit(PCIDevice *dev)
 
 memory_region_destroy(s-ivshmem_mmio);
 memory_region_del_subregion(s-bar, s-ivshmem);
-vmstate_unregister_ram(s-ivshmem, s-dev.qdev);
+vmstate_unregister_ram(s-ivshmem, DEVICE(dev));
 memory_region_destroy(s-ivshmem);
 memory_region_destroy(s-bar);
-unregister_savevm(dev-qdev, ivshmem, s);
+unregister_savevm(DEVICE(dev), ivshmem, s);
 }
 
 static Property ivshmem_properties[] = {
@@ -812,7 +816,7 @@ static void ivshmem_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo ivshmem_info = {
-.name  = ivshmem,
+.name  = TYPE_IVSHMEM,
 .parent= TYPE_PCI_DEVICE,
 .instance_size = sizeof(IVShmemState),
 .class_init= ivshmem_class_init,
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 17/30] pci/*: QOM casting sweep

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Use standard QOM cast macro. Remove usages of DO_UPCAST, container_of()
and direct - style upcasting.

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/pci/pci-hotplug.c | 18 ++
 hw/pci/pci.c | 17 +
 hw/pci/pcie.c|  4 ++--
 hw/pci/shpc.c|  8 
 4 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/hw/pci/pci-hotplug.c b/hw/pci/pci-hotplug.c
index 12287d1..0009190 100644
--- a/hw/pci/pci-hotplug.c
+++ b/hw/pci/pci-hotplug.c
@@ -129,7 +129,7 @@ int pci_drive_hot_add(Monitor *mon, const QDict *qdict, 
DriveInfo *dinfo)
 monitor_printf(mon, no pci device with address %s\n, pci_addr);
 goto err;
 }
-if (scsi_hot_add(mon, dev-qdev, dinfo, 1) != 0) {
+if (scsi_hot_add(mon, DEVICE(dev), dinfo, 1) != 0) {
 goto err;
 }
 break;
@@ -193,11 +193,12 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
 switch (type) {
 case IF_SCSI:
 dev = pci_create(bus, devfn, lsi53c895a);
-if (qdev_init(dev-qdev)  0)
+if (qdev_init(DEVICE(dev))  0) {
 dev = NULL;
+}
 if (dev  dinfo) {
-if (scsi_hot_add(mon, dev-qdev, dinfo, 0) != 0) {
-qdev_unplug(dev-qdev, NULL);
+if (scsi_hot_add(mon, DEVICE(dev), dinfo, 0) != 0) {
+qdev_unplug(DEVICE(dev), NULL);
 dev = NULL;
 }
 }
@@ -208,13 +209,14 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
 return NULL;
 }
 dev = pci_create(bus, devfn, virtio-blk-pci);
-if (qdev_prop_set_drive(dev-qdev, drive, dinfo-bdrv)  0) {
-qdev_free(dev-qdev);
+if (qdev_prop_set_drive(DEVICE(dev), drive, dinfo-bdrv)  0) {
+qdev_free(DEVICE(dev));
 dev = NULL;
 break;
 }
-if (qdev_init(dev-qdev)  0)
+if (qdev_init(DEVICE(dev))  0) {
 dev = NULL;
+}
 break;
 default:
 dev = NULL;
@@ -276,7 +278,7 @@ static int pci_device_hot_remove(Monitor *mon, const char 
*pci_addr)
 return -1;
 }
 
-qdev_unplug(d-qdev, local_err);
+qdev_unplug(DEVICE(d), local_err);
 if (error_is_set(local_err)) {
 monitor_printf(mon, %s\n, error_get_pretty(local_err));
 error_free(local_err);
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index bb3879b..01a754d 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -177,7 +177,7 @@ void pci_device_reset(PCIDevice *dev)
 {
 int r;
 
-qdev_reset_all(dev-qdev);
+qdev_reset_all(DEVICE(dev));
 
 dev-irq_state = 0;
 pci_update_irq_status(dev);
@@ -1449,6 +1449,7 @@ static PciBridgeInfo *qmp_query_pci_bridge(PCIDevice 
*dev, PCIBus *bus,
 static PciDeviceInfo *qmp_query_pci_device(PCIDevice *dev, PCIBus *bus,
int bus_num)
 {
+DeviceState *d = DEVICE(dev);
 const pci_class_desc *desc;
 PciDeviceInfo *info;
 uint8_t type;
@@ -1470,7 +1471,7 @@ static PciDeviceInfo *qmp_query_pci_device(PCIDevice 
*dev, PCIBus *bus,
 info-id.vendor = pci_get_word(dev-config + PCI_VENDOR_ID);
 info-id.device = pci_get_word(dev-config + PCI_DEVICE_ID);
 info-regions = qmp_query_pci_regions(dev);
-info-qdev_id = g_strdup(dev-qdev.id ? dev-qdev.id : );
+info-qdev_id = g_strdup(d-id ? d-id : );
 
 if (dev-config[PCI_INTERRUPT_PIN] != 0) {
 info-has_irq = true;
@@ -1594,7 +1595,7 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char 
*default_model,
 }
 
 pci_dev = pci_create(bus, devfn, pci_nic_names[i]);
-dev = pci_dev-qdev;
+dev = DEVICE(pci_dev);
 qdev_set_nic_properties(dev, nd);
 if (qdev_init(dev)  0)
 return NULL;
@@ -1734,7 +1735,7 @@ static int pci_qdev_init(DeviceState *qdev)
   qdev-hotplugged ? PCI_HOTPLUG_ENABLED:
   PCI_COLDPLUG_ENABLED);
 if (rc != 0) {
-int r = pci_unregister_device(pci_dev-qdev);
+int r = pci_unregister_device(DEVICE(pci_dev));
 assert(!r);
 return rc;
 }
@@ -1771,7 +1772,7 @@ PCIDevice *pci_create_simple_multifunction(PCIBus *bus, 
int devfn,
const char *name)
 {
 PCIDevice *dev = pci_create_multifunction(bus, devfn, multifunction, name);
-qdev_init_nofail(dev-qdev);
+qdev_init_nofail(DEVICE(dev));
 return dev;
 }
 
@@ -1949,7 +1950,7 @@ static int pci_add_option_rom(PCIDevice *pdev, bool 
is_default_rom)
 }
 pdev-has_rom = true;
 memory_region_init_ram(pdev-rom, name, size);
-vmstate_register_ram(pdev-rom, pdev-qdev);
+vmstate_register_ram(pdev-rom, DEVICE(pdev));
 ptr = memory_region_get_ram_ptr(pdev-rom);
 load_image(path, ptr);
 g_free(path);
@@ -1969,7 +1970,7 @@ static void 

[Qemu-devel] [RFT PATCH v1 18/30] pci-bridge/pci_bridge_dev: Don't use DO_UPCAST

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Just use the defined PCI_DEVICE cast macro.

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/pci-bridge/pci_bridge_dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/pci-bridge/pci_bridge_dev.c b/hw/pci-bridge/pci_bridge_dev.c
index 971b432..c845f38 100644
--- a/hw/pci-bridge/pci_bridge_dev.c
+++ b/hw/pci-bridge/pci_bridge_dev.c
@@ -104,7 +104,7 @@ static void pci_bridge_dev_write_config(PCIDevice *d,
 
 static void qdev_pci_bridge_dev_reset(DeviceState *qdev)
 {
-PCIDevice *dev = DO_UPCAST(PCIDevice, qdev, qdev);
+PCIDevice *dev = PCI_DEVICE(qdev);
 
 pci_bridge_reset(qdev);
 shpc_reset(dev);
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 19/30] pci-bridge/*: substitute -qdev casts with DEVICE()

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/pci-bridge/i82801b11.c  | 2 +-
 hw/pci-bridge/ioh3420.c| 2 +-
 hw/pci-bridge/xio3130_downstream.c | 2 +-
 hw/pci-bridge/xio3130_upstream.c   | 2 +-
 hw/pci/pci_bridge.c| 7 ---
 5 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/hw/pci-bridge/i82801b11.c b/hw/pci-bridge/i82801b11.c
index 5807a92..8b20e27 100644
--- a/hw/pci-bridge/i82801b11.c
+++ b/hw/pci-bridge/i82801b11.c
@@ -108,7 +108,7 @@ PCIBus *ich9_d2pbr_init(PCIBus *bus, int devfn, int sec_bus)
 return NULL;
 }
 br = DO_UPCAST(PCIBridge, dev, d);
-qdev = br-dev.qdev;
+qdev = DEVICE(br);
 
 snprintf(buf, sizeof(buf), pci.%d, sec_bus);
 pci_bridge_map_irq(br, buf, pci_swizzle_map_irq_fn);
diff --git a/hw/pci-bridge/ioh3420.c b/hw/pci-bridge/ioh3420.c
index bb541eb..32f9ed6 100644
--- a/hw/pci-bridge/ioh3420.c
+++ b/hw/pci-bridge/ioh3420.c
@@ -173,7 +173,7 @@ PCIESlot *ioh3420_init(PCIBus *bus, int devfn, bool 
multifunction,
 }
 br = DO_UPCAST(PCIBridge, dev, d);
 
-qdev = br-dev.qdev;
+qdev = DEVICE(br);
 pci_bridge_map_irq(br, bus_name, map_irq);
 qdev_prop_set_uint8(qdev, port, port);
 qdev_prop_set_uint8(qdev, chassis, chassis);
diff --git a/hw/pci-bridge/xio3130_downstream.c 
b/hw/pci-bridge/xio3130_downstream.c
index 1810dd2..6a799e2 100644
--- a/hw/pci-bridge/xio3130_downstream.c
+++ b/hw/pci-bridge/xio3130_downstream.c
@@ -140,7 +140,7 @@ PCIESlot *xio3130_downstream_init(PCIBus *bus, int devfn, 
bool multifunction,
 }
 br = DO_UPCAST(PCIBridge, dev, d);
 
-qdev = br-dev.qdev;
+qdev = DEVICE(br);
 pci_bridge_map_irq(br, bus_name, map_irq);
 qdev_prop_set_uint8(qdev, port, port);
 qdev_prop_set_uint8(qdev, chassis, chassis);
diff --git a/hw/pci-bridge/xio3130_upstream.c b/hw/pci-bridge/xio3130_upstream.c
index 8e0d97a..9bb9daa 100644
--- a/hw/pci-bridge/xio3130_upstream.c
+++ b/hw/pci-bridge/xio3130_upstream.c
@@ -120,7 +120,7 @@ PCIEPort *xio3130_upstream_init(PCIBus *bus, int devfn, 
bool multifunction,
 }
 br = DO_UPCAST(PCIBridge, dev, d);
 
-qdev = br-dev.qdev;
+qdev = DEVICE(br);
 pci_bridge_map_irq(br, bus_name, map_irq);
 qdev_prop_set_uint8(qdev, port, port);
 qdev_init_nofail(qdev);
diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c
index 24be6c5..f6657e8 100644
--- a/hw/pci/pci_bridge.c
+++ b/hw/pci/pci_bridge.c
@@ -330,6 +330,7 @@ void pci_bridge_reset(DeviceState *qdev)
 /* default qdev initialization function for PCI-to-PCI bridge */
 int pci_bridge_initfn(PCIDevice *dev, const char *typename)
 {
+DeviceState *d = DEVICE(dev);
 PCIBus *parent = dev-bus;
 PCIBridge *br = DO_UPCAST(PCIBridge, dev, dev);
 PCIBus *sec_bus = br-sec_bus;
@@ -359,11 +360,11 @@ int pci_bridge_initfn(PCIDevice *dev, const char 
*typename)
  * Since PCI Bridge devices have a single bus each, we don't need the 
index:
  * let users address the bus using the device name.
  */
-if (!br-bus_name  dev-qdev.id  *dev-qdev.id) {
-   br-bus_name = dev-qdev.id;
+if (!br-bus_name  d-id  *d-id) {
+br-bus_name = d-id;
 }
 
-qbus_create_inplace(sec_bus-qbus, typename, dev-qdev, br-bus_name);
+qbus_create_inplace(sec_bus-qbus, typename, d, br-bus_name);
 sec_bus-parent_dev = dev;
 sec_bus-map_irq = br-map_irq ? br-map_irq : pci_swizzle_map_irq_fn;
 sec_bus-address_space_mem = br-address_space_mem;
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 20/30] misc/vfio: substitute -qdev casts with DEVICE()

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/misc/vfio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
index 693a9ff..aa75dc2 100644
--- a/hw/misc/vfio.c
+++ b/hw/misc/vfio.c
@@ -3072,7 +3072,7 @@ static int vfio_initfn(PCIDevice *pdev)
 }
 }
 
-add_boot_device_path(vdev-bootindex, pdev-qdev, NULL);
+add_boot_device_path(vdev-bootindex, DEVICE(pdev), NULL);
 
 return 0;
 
@@ -3106,7 +3106,7 @@ static void vfio_exitfn(PCIDevice *pdev)
 
 static void vfio_pci_reset(DeviceState *dev)
 {
-PCIDevice *pdev = DO_UPCAST(PCIDevice, qdev, dev);
+PCIDevice *pdev = PCI_DEVICE(dev);
 VFIODevice *vdev = DO_UPCAST(VFIODevice, pdev, pdev);
 uint16_t cmd;
 
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 21/30] net/eepro100: substitute -qdev casts with DEVICE()

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/net/eepro100.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index dc99ea6..f34b5dc 100644
--- a/hw/net/eepro100.c
+++ b/hw/net/eepro100.c
@@ -1842,13 +1842,14 @@ static void nic_cleanup(NetClientState *nc)
 
 static void pci_nic_uninit(PCIDevice *pci_dev)
 {
+DeviceState *d = DEVICE(pci_dev);
 EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);
 
 memory_region_destroy(s-mmio_bar);
 memory_region_destroy(s-io_bar);
 memory_region_destroy(s-flash_bar);
-vmstate_unregister(pci_dev-qdev, s-vmstate, s);
-eeprom93xx_free(pci_dev-qdev, s-eeprom);
+vmstate_unregister(d, s-vmstate, s);
+eeprom93xx_free(d, s-eeprom);
 qemu_del_nic(s-nic);
 }
 
@@ -1862,6 +1863,7 @@ static NetClientInfo net_eepro100_info = {
 
 static int e100_nic_init(PCIDevice *pci_dev)
 {
+DeviceState *d = DEVICE(pci_dev);
 EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);
 E100PCIDeviceInfo *info = eepro100_get_class(s);
 
@@ -1873,7 +1875,7 @@ static int e100_nic_init(PCIDevice *pci_dev)
 
 /* Add 64 * 2 EEPROM. i82557 and i82558 support a 64 word EEPROM,
  * i82559 and later support 64 or 256 word EEPROM. */
-s-eeprom = eeprom93xx_new(pci_dev-qdev, EEPROM_SIZE);
+s-eeprom = eeprom93xx_new(d, EEPROM_SIZE);
 
 /* Handler for memory-mapped I/O */
 memory_region_init_io(s-mmio_bar, eepro100_ops, s, eepro100-mmio,
@@ -1893,7 +1895,7 @@ static int e100_nic_init(PCIDevice *pci_dev)
 nic_reset(s);
 
 s-nic = qemu_new_nic(net_eepro100_info, s-conf,
-  object_get_typename(OBJECT(pci_dev)), 
pci_dev-qdev.id, s);
+  object_get_typename(OBJECT(pci_dev)), d-id, s);
 
 qemu_format_nic_info_str(qemu_get_queue(s-nic), s-conf.macaddr.a);
 TRACE(OTHER, logout(%s\n, qemu_get_queue(s-nic)-info_str));
@@ -1903,9 +1905,9 @@ static int e100_nic_init(PCIDevice *pci_dev)
 s-vmstate = g_malloc(sizeof(vmstate_eepro100));
 memcpy(s-vmstate, vmstate_eepro100, sizeof(vmstate_eepro100));
 s-vmstate-name = qemu_get_queue(s-nic)-model;
-vmstate_register(pci_dev-qdev, -1, s-vmstate, s);
+vmstate_register(d, -1, s-vmstate, s);
 
-add_boot_device_path(s-conf.bootindex, pci_dev-qdev, /ethernet-phy@0);
+add_boot_device_path(s-conf.bootindex, d, /ethernet-phy@0);
 
 return 0;
 }
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 22/30] net/ne2000: substitute -qdev casts with DEVICE()

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/net/ne2000.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c
index 33ee03e..70a7991 100644
--- a/hw/net/ne2000.c
+++ b/hw/net/ne2000.c
@@ -722,6 +722,8 @@ static NetClientInfo net_ne2000_info = {
 static int pci_ne2000_init(PCIDevice *pci_dev)
 {
 PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
+DeviceState *ds = DEVICE(pci_dev);
+
 NE2000State *s;
 uint8_t *pci_conf;
 
@@ -737,10 +739,10 @@ static int pci_ne2000_init(PCIDevice *pci_dev)
 ne2000_reset(s);
 
 s-nic = qemu_new_nic(net_ne2000_info, s-c,
-  object_get_typename(OBJECT(pci_dev)), 
pci_dev-qdev.id, s);
+  object_get_typename(OBJECT(pci_dev)), ds-id, s);
 qemu_format_nic_info_str(qemu_get_queue(s-nic), s-c.macaddr.a);
 
-add_boot_device_path(s-c.bootindex, pci_dev-qdev, /ethernet-phy@0);
+add_boot_device_path(s-c.bootindex, ds, /ethernet-phy@0);
 
 return 0;
 }
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 23/30] usb/*: substitute -qdev casts with DEVICE()

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/usb/hcd-ehci-pci.c | 13 -
 hw/usb/hcd-ohci.c |  2 +-
 hw/usb/hcd-uhci.c |  2 +-
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c
index 0eb7826..c772e1f 100644
--- a/hw/usb/hcd-ehci-pci.c
+++ b/hw/usb/hcd-ehci-pci.c
@@ -197,6 +197,7 @@ int ehci_create_ich9_with_companions(PCIBus *bus, int slot)
 const struct ehci_companions *comp;
 PCIDevice *ehci, *uhci;
 BusState *usbbus;
+DeviceState *dev;
 const char *name;
 int i;
 
@@ -214,15 +215,17 @@ int ehci_create_ich9_with_companions(PCIBus *bus, int 
slot)
 }
 
 ehci = pci_create_multifunction(bus, PCI_DEVFN(slot, 7), true, name);
-qdev_init_nofail(ehci-qdev);
-usbbus = QLIST_FIRST(ehci-qdev.child_bus);
+dev = DEVICE(ehci);
+qdev_init_nofail(dev);
+usbbus = QLIST_FIRST(dev-child_bus);
 
 for (i = 0; i  3; i++) {
 uhci = pci_create_multifunction(bus, PCI_DEVFN(slot, comp[i].func),
 true, comp[i].name);
-qdev_prop_set_string(uhci-qdev, masterbus, usbbus-name);
-qdev_prop_set_uint32(uhci-qdev, firstport, comp[i].port);
-qdev_init_nofail(uhci-qdev);
+dev = DEVICE(uhci);
+qdev_prop_set_string(dev, masterbus, usbbus-name);
+qdev_prop_set_uint32(dev, firstport, comp[i].port);
+qdev_init_nofail(dev);
 }
 return 0;
 }
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index 51241cd..62c08ee 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -1857,7 +1857,7 @@ static int usb_ohci_initfn_pci(struct PCIDevice *dev)
 ohci-pci_dev.config[PCI_CLASS_PROG] = 0x10; /* OHCI */
 ohci-pci_dev.config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin A */
 
-if (usb_ohci_init(ohci-state, dev-qdev, ohci-num_ports, 0,
+if (usb_ohci_init(ohci-state, DEVICE(dev), ohci-num_ports, 0,
   ohci-masterbus, ohci-firstport,
   pci_dma_context(dev)) != 0) {
 return -1;
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index c85b203..67c13c3 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -1246,7 +1246,7 @@ static int usb_uhci_common_initfn(PCIDevice *dev)
 return -1;
 }
 } else {
-usb_bus_new(s-bus, uhci_bus_ops, s-dev.qdev);
+usb_bus_new(s-bus, uhci_bus_ops, DEVICE(dev));
 for (i = 0; i  NB_PORTS; i++) {
 usb_register_port(s-bus, s-ports[i].port, s, i, uhci_port_ops,
   USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 24/30] watchdog/wdt_i6300esb: substitute -qdev casts with DEVICE()

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/watchdog/wdt_i6300esb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/watchdog/wdt_i6300esb.c b/hw/watchdog/wdt_i6300esb.c
index 1407fba..df39d9c 100644
--- a/hw/watchdog/wdt_i6300esb.c
+++ b/hw/watchdog/wdt_i6300esb.c
@@ -195,7 +195,7 @@ static void i6300esb_timer_expired(void *vp)
 if (d-reboot_enabled) {
 d-previous_reboot_flag = 1;
 watchdog_perform_action(); /* This reboots, exits, etc */
-i6300esb_reset(d-dev.qdev);
+i6300esb_reset(DEVICE(d));
 }
 
 /* In free running mode we start stage 1 again. */
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 25/30] scsi/vmw_pvscsi: substitute -qdev casts with DEVICE()

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/scsi/vmw_pvscsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c
index 48d12f4..e9cf15f 100644
--- a/hw/scsi/vmw_pvscsi.c
+++ b/hw/scsi/vmw_pvscsi.c
@@ -1088,7 +1088,7 @@ pvscsi_init(PCIDevice *pci_dev)
 return -ENOMEM;
 }
 
-scsi_bus_new(s-bus, pci_dev-qdev, pvscsi_scsi_info, NULL);
+scsi_bus_new(s-bus, DEVICE(pci_dev), pvscsi_scsi_info, NULL);
 pvscsi_reset_state(s);
 
 return 0;
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 26/30] i2c/smbus_ich9: substitute -qdev casts with DEVICE()

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/i2c/smbus_ich9.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/i2c/smbus_ich9.c b/hw/i2c/smbus_ich9.c
index ca22978..f87343f 100644
--- a/hw/i2c/smbus_ich9.c
+++ b/hw/i2c/smbus_ich9.c
@@ -82,7 +82,7 @@ static int ich9_smbus_initfn(PCIDevice *d)
 pci_set_byte(d-config + ICH9_SMB_HOSTC, 0);
 /* TODO bar0, bar1: 64bit BAR support*/
 
-pm_smbus_init(d-qdev, s-smb);
+pm_smbus_init(DEVICE(d), s-smb);
 pci_register_bar(d, ICH9_SMB_SMB_BASE_BAR, PCI_BASE_ADDRESS_SPACE_IO,
  s-smb.io);
 return 0;
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 27/30] ide/cmd646: substitute -qdev casts with DEVICE()

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/ide/cmd646.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c
index a73eb9a..9544c1f 100644
--- a/hw/ide/cmd646.c
+++ b/hw/ide/cmd646.c
@@ -281,7 +281,7 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev)
 
 irq = qemu_allocate_irqs(cmd646_set_irq, d, 2);
 for (i = 0; i  2; i++) {
-ide_bus_new(d-bus[i], d-dev.qdev, i, 2);
+ide_bus_new(d-bus[i], DEVICE(d), i, 2);
 ide_init2(d-bus[i], irq[i]);
 
 bmdma_init(d-bus[i], d-bmdma[i], d);
@@ -290,7 +290,7 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev)
  d-bmdma[i].dma);
 }
 
-vmstate_register(dev-qdev, 0, vmstate_ide_pci, d);
+vmstate_register(DEVICE(dev), 0, vmstate_ide_pci, d);
 qemu_register_reset(cmd646_reset, d);
 return 0;
 }
@@ -317,8 +317,8 @@ void pci_cmd646_ide_init(PCIBus *bus, DriveInfo **hd_table,
 PCIDevice *dev;
 
 dev = pci_create(bus, -1, cmd646-ide);
-qdev_prop_set_uint32(dev-qdev, secondary, secondary_ide_enabled);
-qdev_init_nofail(dev-qdev);
+qdev_prop_set_uint32(DEVICE(dev), secondary, secondary_ide_enabled);
+qdev_init_nofail(DEVICE(dev));
 
 pci_ide_create_devs(dev, hd_table);
 }
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 28/30] ide/via: substitute -qdev casts with DEVICE()

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/ide/via.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/ide/via.c b/hw/ide/via.c
index 5fe053c..b81e1fe 100644
--- a/hw/ide/via.c
+++ b/hw/ide/via.c
@@ -158,7 +158,7 @@ static void vt82c686b_init_ports(PCIIDEState *d) {
 int i;
 
 for (i = 0; i  2; i++) {
-ide_bus_new(d-bus[i], d-dev.qdev, i, 2);
+ide_bus_new(d-bus[i], DEVICE(d), i, 2);
 ide_init_ioport(d-bus[i], NULL, port_info[i].iobase,
 port_info[i].iobase2);
 ide_init2(d-bus[i], isa_get_irq(NULL, port_info[i].isairq));
@@ -183,7 +183,7 @@ static int vt82c686b_ide_initfn(PCIDevice *dev)
 bmdma_setup_bar(d);
 pci_register_bar(d-dev, 4, PCI_BASE_ADDRESS_SPACE_IO, d-bmdma_bar);
 
-vmstate_register(dev-qdev, 0, vmstate_ide_pci, d);
+vmstate_register(DEVICE(dev), 0, vmstate_ide_pci, d);
 
 vt82c686b_init_ports(d);
 
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 29/30] pci-host/*: substitute -qdev casts with DEVICE()

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/pci-bridge/dec.c | 2 +-
 hw/pci-host/apb.c   | 4 ++--
 hw/pci-host/q35.c   | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/pci-bridge/dec.c b/hw/pci-bridge/dec.c
index cff458b..1e5611d 100644
--- a/hw/pci-bridge/dec.c
+++ b/hw/pci-bridge/dec.c
@@ -88,7 +88,7 @@ PCIBus *pci_dec_21154_init(PCIBus *parent_bus, int devfn)
dec-21154-p2p-bridge);
 br = DO_UPCAST(PCIBridge, dev, dev);
 pci_bridge_map_irq(br, DEC 21154 PCI-PCI bridge, dec_map_irq);
-qdev_init_nofail(dev-qdev);
+qdev_init_nofail(DEVICE(dev));
 return pci_bridge_get_sec_bus(br);
 }
 
diff --git a/hw/pci-host/apb.c b/hw/pci-host/apb.c
index e099655..f3987ff 100644
--- a/hw/pci-host/apb.c
+++ b/hw/pci-host/apb.c
@@ -467,7 +467,7 @@ PCIBus *pci_apb_init(hwaddr special_base,
 br = DO_UPCAST(PCIBridge, dev, pci_dev);
 pci_bridge_map_irq(br, Advanced PCI Bus secondary bridge 1,
pci_apb_map_irq);
-qdev_init_nofail(pci_dev-qdev);
+qdev_init_nofail(DEVICE(dev));
 *bus2 = pci_bridge_get_sec_bus(br);
 
 pci_dev = pci_create_multifunction(d-bus, PCI_DEVFN(1, 1), true,
@@ -475,7 +475,7 @@ PCIBus *pci_apb_init(hwaddr special_base,
 br = DO_UPCAST(PCIBridge, dev, pci_dev);
 pci_bridge_map_irq(br, Advanced PCI Bus secondary bridge 2,
pci_apb_map_irq);
-qdev_init_nofail(pci_dev-qdev);
+qdev_init_nofail(DEVICE(pci_dev));
 *bus3 = pci_bridge_get_sec_bus(br);
 
 return d-bus;
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index 24df6b5..d04471c 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -104,8 +104,8 @@ static const TypeInfo q35_host_info = {
 /* PCIe MMCFG */
 static void mch_update_pciexbar(MCHPCIState *mch)
 {
-PCIDevice *pci_dev = mch-d;
-BusState *bus = qdev_get_parent_bus(pci_dev-qdev);
+PCIDevice *pci_dev = PCI_DEVICE(mch);
+BusState *bus = qdev_get_parent_bus(DEVICE(pci_dev));
 DeviceState *qdev = bus-parent;
 Q35PCIHost *s = Q35_HOST_DEVICE(qdev);
 
-- 
1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [RFT PATCH v1 30/30] i386/*: substitute -qdev casts with DEVICE()

2013-06-11 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 hw/i386/kvm/pci-assign.c | 21 -
 hw/i386/pc.c |  4 ++--
 hw/i386/pc_piix.c|  4 ++--
 hw/i386/pc_q35.c |  4 ++--
 4 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c
index ff85590..d9c2436 100644
--- a/hw/i386/kvm/pci-assign.c
+++ b/hw/i386/kvm/pci-assign.c
@@ -491,7 +491,7 @@ static int assigned_dev_register_regions(PCIRegion 
*io_regions,
name, cur_region-size,
virtbase);
 vmstate_register_ram(pci_dev-v_addrs[i].real_iomem,
- pci_dev-dev.qdev);
+ DEVICE(pci_dev-dev));
 }
 
 assigned_dev_iomem_setup(pci_dev-dev, i, cur_region-size);
@@ -817,6 +817,7 @@ fail:
 
 static int assign_device(AssignedDevice *dev)
 {
+DeviceState *d = DEVICE(dev-dev);
 uint32_t flags = KVM_DEV_ASSIGN_ENABLE_IOMMU;
 int r;
 
@@ -830,7 +831,7 @@ static int assign_device(AssignedDevice *dev)
 
 if (!kvm_check_extension(kvm_state, KVM_CAP_IOMMU)) {
 error_report(No IOMMU found.  Unable to assign device \%s\,
- dev-dev.qdev.id);
+ d-id);
 return -ENODEV;
 }
 
@@ -842,7 +843,7 @@ static int assign_device(AssignedDevice *dev)
 r = kvm_device_pci_assign(kvm_state, dev-host, flags, dev-dev_id);
 if (r  0) {
 error_report(Failed to assign device \%s\ : %s,
- dev-dev.qdev.id, strerror(-r));
+ d-id, strerror(-r));
 
 switch (r) {
 case -EBUSY:
@@ -867,6 +868,7 @@ static bool check_irqchip_in_kernel(void)
 
 static int assign_intx(AssignedDevice *dev)
 {
+DeviceState *d = DEVICE(dev-dev);
 AssignedIRQType new_type;
 PCIINTxRoute intx_route;
 bool intx_host_msi;
@@ -942,7 +944,7 @@ retry:
 goto retry;
 }
 error_report(Failed to assign irq for \%s\: %s,
- dev-dev.qdev.id, strerror(-r));
+ d-id, strerror(-r));
 error_report(Perhaps you are assigning a device 
  that shares an IRQ with another device?);
 return r;
@@ -972,7 +974,7 @@ static void assigned_dev_update_irq_routing(PCIDevice *dev)
 
 r = assign_intx(assigned_dev);
 if (r  0) {
-qdev_unplug(dev-qdev, err);
+qdev_unplug(DEVICE(dev), err);
 assert(!err);
 }
 }
@@ -1675,7 +1677,7 @@ static const VMStateDescription vmstate_assigned_device = 
{
 
 static void reset_assigned_device(DeviceState *dev)
 {
-PCIDevice *pci_dev = DO_UPCAST(PCIDevice, qdev, dev);
+PCIDevice *pci_dev = PCI_DEVICE(dev);
 AssignedDevice *adev = DO_UPCAST(AssignedDevice, dev, pci_dev);
 char reset_file[64];
 const char reset[] = 1;
@@ -1731,6 +1733,7 @@ static void reset_assigned_device(DeviceState *dev)
 
 static int assigned_initfn(struct PCIDevice *pci_dev)
 {
+DeviceState *d = DEVICE(pci_dev);
 AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
 uint8_t e_intx;
 int r;
@@ -1769,7 +1772,7 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
 if (get_real_device(dev, dev-host.domain, dev-host.bus,
 dev-host.slot, dev-host.function)) {
 error_report(pci-assign: Error: Couldn't get real device (%s)!,
- dev-dev.qdev.id);
+ d-id);
 goto out;
 }
 
@@ -1811,7 +1814,7 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
 
 assigned_dev_load_option_rom(dev);
 
-add_boot_device_path(dev-bootindex, pci_dev-qdev, NULL);
+add_boot_device_path(dev-bootindex, d, NULL);
 
 return 0;
 
@@ -1916,7 +1919,7 @@ static void assigned_dev_load_option_rom(AssignedDevice 
*dev)
 snprintf(name, sizeof(name), %s.rom,
 object_get_typename(OBJECT(dev)));
 memory_region_init_ram(dev-dev.rom, name, st.st_size);
-vmstate_register_ram(dev-dev.rom, dev-dev.qdev);
+vmstate_register_ram(dev-dev.rom, DEVICE(dev-dev));
 ptr = memory_region_get_ram_ptr(dev-dev.rom);
 memset(ptr, 0xff, st.st_size);
 
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 4844a6b..120f02c 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1085,10 +1085,10 @@ DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus 
*pci_bus)
 
 if (pci_bus) {
 PCIDevice *pcidev = pci_vga_init(pci_bus);
-dev = pcidev ? pcidev-qdev : NULL;
+dev = DEVICE(pcidev);
 } else if (isa_bus) {
 ISADevice *isadev = isa_vga_init(isa_bus);
-dev = isadev ? isadev-qdev : NULL;
+dev = DEVICE(isadev);
 }
 return dev;
 }
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index d618570..1b40f24 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c

Re: [Qemu-devel] [RFT PATCH v1 12/30] virtio/virtio-pci: QOM casting sweep

2013-06-11 Thread Frederic Konrad

Hi,

On 11/06/2013 08:49, peter.crosthwa...@xilinx.com wrote:

From: Peter Crosthwaite peter.crosthwa...@xilinx.com

Use standard QOM cast macro. Remove usages of container_of() and
direct - style upcasting.

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com

[...]

  static inline VirtIOPCIProxy *to_virtio_pci_proxy(DeviceState *d)
  {
-return container_of(d, VirtIOPCIProxy, pci_dev.qdev);
+return VIRTIO_PCI(d);
  }


Maybe you can replace each to_virtio_pci_proxy directly with VIRTIO_PCI?
  
  /* DeviceState to VirtIOPCIProxy. Note: used on datapath,

@@ -106,7 +106,7 @@ static inline VirtIOPCIProxy 
*to_virtio_pci_proxy(DeviceState *d)
   */
  static inline VirtIOPCIProxy *to_virtio_pci_proxy_fast(DeviceState *d)
  {
-return container_of(d, VirtIOPCIProxy, pci_dev.qdev);
+return VIRTIO_PCI(d);
  }
  
  static void virtio_pci_notify(DeviceState *d, uint16_t vector)





Re: [Qemu-devel] [PATCH] virtio-scsi: forward scsibus for virtio-scsi-pci.

2013-06-11 Thread Michael S. Tsirkin
On Tue, Jun 11, 2013 at 08:43:51AM +0200, Frederic Konrad wrote:
 On 10/06/2013 19:00, Michael S. Tsirkin wrote:
 On Mon, Jun 10, 2013 at 11:53:04AM +0200, fred.kon...@greensocs.com wrote:
 From: KONRAD Frederic fred.kon...@greensocs.com
 
 This fix a bug with scsi hotplug on virtio-scsi-pci:
 
 As virtio-scsi-pci doesn't have any scsi bus, we need to forward 
 scsi-hot-add
 to the virtio-scsi-device plugged on the virtio-bus.
 
 Reported-by: Alexey Kardashevskiy a...@ozlabs.ru
 Signed-off-by: KONRAD Frederic fred.kon...@greensocs.com
 ---
   hw/pci/pci-hotplug.c | 19 +--
   1 file changed, 17 insertions(+), 2 deletions(-)
 
 diff --git a/hw/pci/pci-hotplug.c b/hw/pci/pci-hotplug.c
 index 12287d1..c708752 100644
 --- a/hw/pci/pci-hotplug.c
 +++ b/hw/pci/pci-hotplug.c
 @@ -30,6 +30,8 @@
   #include monitor/monitor.h
   #include hw/scsi/scsi.h
   #include hw/virtio/virtio-blk.h
 +#include hw/virtio/virtio-scsi.h
 +#include hw/virtio/virtio-pci.h
   #include qemu/config-file.h
   #include sysemu/blockdev.h
   #include qapi/error.h
 @@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState 
 *adapter,
   {
   SCSIBus *scsibus;
   SCSIDevice *scsidev;
 +VirtIOPCIProxy *virtio_proxy;
   scsibus = (SCSIBus *)
   object_dynamic_cast(OBJECT(QLIST_FIRST(adapter-child_bus)),
   TYPE_SCSI_BUS);
   if (!scsibus) {
 -   error_report(Device is not a SCSI adapter);
 -   return -1;
 +/*
 + * Check if the adapter is a virtio-scsi-pci, and forward 
 scsi_hot_add
 + * to the virtio-scsi-device.
 + */
 +if (!object_dynamic_cast(OBJECT(adapter), TYPE_VIRTIO_SCSI_PCI)) {
 +error_report(Device is not a SCSI adapter);
 +return -1;
 +}
 +virtio_proxy = VIRTIO_PCI(adapter);
 +adapter = DEVICE(virtio_proxy-bus.vdev);
 +scsibus = (SCSIBus *)
 +  
 object_dynamic_cast(OBJECT(QLIST_FIRST(adapter-child_bus)),
 +TYPE_SCSI_BUS);
 +assert(scsibus);
   }
   /*
 By the way I really wonder. pci-hotplug.c was supposed to
 be legacy interface.
 Is this the only way to add scsi disks?
 And are other ways broken, too?
 
 Here you can add scsi disks to a given device.
 I think the other ways add scsi disks to a given bus?
 
 Do you see any other?
 
 Thanks,
 Fred

I don't know, that's why I'm asking.

If it is, that's crazy. There's no reason for
it to be tied to pci at all.

The commands in pci-hotplug.c are legacy - they don't support things
like multi root systems and there's no sane way to make them do it.

Your patch probably makes sense for stable, but for 1.6,
let's fix this properly.

 
 -- 
 1.8.1.4



Re: [Qemu-devel] [PATCH 2/2] Add monitor command mem-nodes

2013-06-11 Thread Wanlong Gao
On 06/05/2013 09:46 PM, Eduardo Habkost wrote:
 On Wed, Jun 05, 2013 at 11:58:25AM +0800, Wanlong Gao wrote:
 Add monitor command mem-nodes to show the huge mapped
 memory nodes locations.

 
 This is for machine consumption, so we need a QMP command.
 
 (qemu) info mem-nodes
 /proc/14132/fd/13: 2ac0-2aaaeac0: node0
 /proc/14132/fd/13: 2aaaeac0-2aab2ac0: node1
 /proc/14132/fd/14: 2aab2ac0-2aab2b00: node0
 /proc/14132/fd/14: 2aab2b00-2aab2b40: node1
 
 Are node0/node1 _host_ nodes?
 
 How do I know what's the _guest_ address/node corresponding to each
 file/range above?
 
 What I am really looking for is:
 
  * The correspondence between guest (virtual) NUMA nodes and guest
physical address ranges (it could be provided by the QMP version of
info numa)

AFAIK, the guest NUMA nodes and guest physical address ranges are set
by seabios, we can't get this information from QEMU, and I think this
information is useless for pinning memory range to host.

  * The correspondence between guest physical address ranges and ranges
inside the mapped files (so external tools could set the policy on
those files instead of requiring QEMU to set it directly)
 
 I understand that your use case may require additional information and
 additional interfaces. But if we provide the information above we will
 allow external components set the policy on the hugetlbfs files before
 we add new interfaces required for your use case.

But the file backed memory is not good for the host which has many
virtual machines, in this situation, we can't handle anon THP yet.

And as I mentioned, the cross numa node access performance regression
is caused by pci-passthrough, it's a very long time bug, we should
back port the host memory pinning patch to old QEMU to resolve this performance
problem, too.

Thanks,
Wanlong Gao

 
 Also, what about making it conditional to OSes where we really know
 /proc/pid/fd/fd is available?
 
 

 Refer to the proposal of Eduardo and Daniel.
 http://article.gmane.org/gmane.comp.emulators.kvm.devel/93476
 

 Signed-off-by: Wanlong Gao gaowanl...@cn.fujitsu.com
 ---
  monitor.c | 45 +
  1 file changed, 45 insertions(+)

 diff --git a/monitor.c b/monitor.c
 index eefc7f0..85c865f 100644
 --- a/monitor.c
 +++ b/monitor.c
 @@ -74,6 +74,10 @@
  #endif
  #include hw/lm32/lm32_pic.h
  
 +#if defined(CONFIG_NUMA)
 +#include numaif.h
 +#endif
 +
  //#define DEBUG
  //#define DEBUG_COMPLETION
  
 @@ -1759,6 +1763,38 @@ static void mem_info(Monitor *mon, const QDict *qdict)
  }
  #endif
  
 +#if defined(CONFIG_NUMA)
 +static void mem_nodes(Monitor *mon, const QDict *qdict)
 +{
 +RAMBlock *block;
 +int prevnode, node;
 +unsigned long long c, start, area;
 +int fd;
 +int pid = getpid();
 +QTAILQ_FOREACH(block, ram_list.blocks, next) {
 +if (!(fd = block-fd))
 +continue;
 +prevnode = -1;
 +start = 0;
 +area = (unsigned long long)block-host;
 +for (c = 0; c  block-length; c += TARGET_PAGE_SIZE) {
 +if (get_mempolicy(node, NULL, 0, c + block-host,
 +  MPOL_F_ADDR | MPOL_F_NODE)  0)
 +continue;
 +if (node == prevnode)
 +continue;
 +if (prevnode != -1)
 +monitor_printf(mon, /proc/%d/fd/%d: %016Lx-%016Lx: 
 node%d\n,
 +   pid, fd, start + area, c + area, prevnode);
 +prevnode = node;
 +start = c;
 + }
 + monitor_printf(mon, /proc/%d/fd/%d: %016Lx-%016Lx: node%d\n,
 +pid, fd, start + area, c + area, prevnode);
 +}
 +}
 +#endif
 +
  #if defined(TARGET_SH4)
  
  static void print_tlb(Monitor *mon, int idx, tlb_t *tlb)
 @@ -2567,6 +2603,15 @@ static mon_cmd_t info_cmds[] = {
  .mhandler.cmd = mem_info,
  },
  #endif
 +#if defined(CONFIG_NUMA)
 +{
 +.name   = mem-nodes,
 +.args_type  = ,
 +.params = ,
 +.help   = show the huge mapped memory nodes location,
 +.mhandler.cmd = mem_nodes,
 +},
 +#endif
  {
  .name   = mtree,
  .args_type  = ,
 -- 
 1.8.3.rc2.10.g0c2b1cf

 




Re: [Qemu-devel] [PATCH] virtio-scsi: forward scsibus for virtio-scsi-pci.

2013-06-11 Thread Frederic Konrad

On 11/06/2013 09:21, Michael S. Tsirkin wrote:

On Tue, Jun 11, 2013 at 08:43:51AM +0200, Frederic Konrad wrote:

On 10/06/2013 19:00, Michael S. Tsirkin wrote:

On Mon, Jun 10, 2013 at 11:53:04AM +0200, fred.kon...@greensocs.com wrote:

From: KONRAD Frederic fred.kon...@greensocs.com

This fix a bug with scsi hotplug on virtio-scsi-pci:

As virtio-scsi-pci doesn't have any scsi bus, we need to forward scsi-hot-add
to the virtio-scsi-device plugged on the virtio-bus.

Reported-by: Alexey Kardashevskiy a...@ozlabs.ru
Signed-off-by: KONRAD Frederic fred.kon...@greensocs.com
---
  hw/pci/pci-hotplug.c | 19 +--
  1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/hw/pci/pci-hotplug.c b/hw/pci/pci-hotplug.c
index 12287d1..c708752 100644
--- a/hw/pci/pci-hotplug.c
+++ b/hw/pci/pci-hotplug.c
@@ -30,6 +30,8 @@
  #include monitor/monitor.h
  #include hw/scsi/scsi.h
  #include hw/virtio/virtio-blk.h
+#include hw/virtio/virtio-scsi.h
+#include hw/virtio/virtio-pci.h
  #include qemu/config-file.h
  #include sysemu/blockdev.h
  #include qapi/error.h
@@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState *adapter,
  {
  SCSIBus *scsibus;
  SCSIDevice *scsidev;
+VirtIOPCIProxy *virtio_proxy;
  scsibus = (SCSIBus *)
  object_dynamic_cast(OBJECT(QLIST_FIRST(adapter-child_bus)),
  TYPE_SCSI_BUS);
  if (!scsibus) {
-   error_report(Device is not a SCSI adapter);
-   return -1;
+/*
+ * Check if the adapter is a virtio-scsi-pci, and forward scsi_hot_add
+ * to the virtio-scsi-device.
+ */
+if (!object_dynamic_cast(OBJECT(adapter), TYPE_VIRTIO_SCSI_PCI)) {
+error_report(Device is not a SCSI adapter);
+return -1;
+}
+virtio_proxy = VIRTIO_PCI(adapter);
+adapter = DEVICE(virtio_proxy-bus.vdev);
+scsibus = (SCSIBus *)
+  object_dynamic_cast(OBJECT(QLIST_FIRST(adapter-child_bus)),
+TYPE_SCSI_BUS);
+assert(scsibus);
  }
  /*

By the way I really wonder. pci-hotplug.c was supposed to
be legacy interface.
Is this the only way to add scsi disks?
And are other ways broken, too?

Here you can add scsi disks to a given device.
I think the other ways add scsi disks to a given bus?

Do you see any other?

Thanks,
Fred

I don't know, that's why I'm asking.

If it is, that's crazy. There's no reason for
it to be tied to pci at all.

The commands in pci-hotplug.c are legacy - they don't support things
like multi root systems and there's no sane way to make them do it.

Your patch probably makes sense for stable, but for 1.6,
let's fix this properly.


Ok, what do you propose to fix that properly?

If we want to keep the behaviour of drive_add command, I
think we have two solutions:
A/ Change the scsi_hot_add to check if it is a virtio-scsi-pci 
device and take

virtio-scsi-device's scsi bus.
B/ Make somehow virtio-scsi-pci having a scsi-bus
(and the same in virtio-scsi-device).

I chose A because it seems a lot easier. For the moment B seems not 
possible,

but would it be a cleaner solution? What do you think?

Fred



--
1.8.1.4





Re: [Qemu-devel] [PATCH] qemu: piix: PCI bridge ACPI hotplug support

2013-06-11 Thread Michael S. Tsirkin
On Mon, Jun 10, 2013 at 08:03:46PM -0500, Anthony Liguori wrote:
  It is not supported by QEMU.
 
  No, but I've always thought that QEMU was happy to have alternative
  firmware projects.
 
 We are and we're happy to accept patches to enable things even if its
 proprietary.  But that's all assuming we're improving hardware
 emulation.
 
 What we're talking about here is doing something that's very un-hardware like.

Two points
1. You never explained what you mean by un-hardware like.

   Currently bios is in a ROM device, and it has a
   template for ACPI tables together with it.
   This simply moves the tables to a separate ROM
   device (FW CFG), and generalizes the template using
   the linker interface.
   One ROM is hardware-like but two is un-hardware like?

   ACPI tables are static so it's likely lots of
   hardware has at least some of them pre-formatted in flash,
   then tweak some things like SRAT a bit.

2. There's no hardware-like alternative.

   A current alternative is exposing lots of PV interfaces to bios,
   bios builds up ACPI tables based on them.
   All of this code is in practice PC only,
   if we ever attempt to generalize we'll see how
   the interfaces are not a good match.
   They are still PV, poorly documented and it's very hard for
   bios not to make any assumptions about them.
   When it does, result is a very obscure breakage.

   Yes, building tables in bios means
   QEMU code is simpler but we double the
   amount of interfaces that we need to get right:
   QEMU-BIOS + BIOS-OS

   Yes it's not QEMU code but it's seen as
   a single package by users and it does not really
   matter - excellent hardware with lousy firmware is
   useless.

-- 
MST



Re: [Qemu-devel] [PATCH] ide-test: fix failure for test_flush

2013-06-11 Thread Kevin Wolf
Am 10.06.2013 um 20:23 hat Michael Roth geschrieben:
 bd07684aacfb61668ae2c25b7dd00b64f3d7c7f3 added a test to ensure BSY
 flag is set when a flush request is in flight. It does this by setting
 a blkdebug breakpoint on flush_to_os before issuing a CMD_FLUSH_CACHE.
 It then resumes CMD_FLUSH_CACHE operation and checks that BSY is unset.
 
 The actual unsetting of BSY does not occur until ide_flush_cb gets
 called in a bh, however, so in some cases this check will race with
 the actual completion.
 
 Fix this by polling the ide status register until BSY flag gets unset
 before we do our final sanity checks. According to
 f68ec8379e88502b4841a110c070e9b118d3151c this is in line with how a guest
 would determine whether or not the device is still busy.
 
 Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com

Thanks, applied to the block branch.

Kevin



Re: [Qemu-devel] [PATCH] curl: refuse to open URL from HTTP server without range support

2013-06-11 Thread Stefan Hajnoczi
On Tue, Jun 11, 2013 at 11:15:15AM +0800, Fam Zheng wrote:
 On Mon, Jun 10, 2013 at 5:21 PM, Stefan Hajnoczi stefa...@gmail.com wrote:
  On Sun, Jun 09, 2013 at 10:34:54AM +0800, Fam Zheng wrote:
  @@ -110,14 +111,14 @@ static int curl_sock_cb(CURL *curl, curl_socket_t 
  fd, int action,
   return 0;
   }
 
  -static size_t curl_size_cb(void *ptr, size_t size, size_t nmemb, void 
  *opaque)
  +static size_t curl_header_cb(void *ptr, size_t size, size_t nmemb, void 
  *opaque)
   {
  -CURLState *s = ((CURLState*)opaque);
  +BDRVCURLState *s = opaque;
   size_t realsize = size * nmemb;
  -size_t fsize;
  +const char *accept_line = Accept-Ranges: bytes;
 
  -if(sscanf(ptr, Content-Length: %zd, fsize) == 1) {
  -s-s-len = fsize;
  +if (strncmp((char *)ptr, accept_line, strlen(accept_line)) == 0) {
  +s-accept_range = true;
   }
 
  This still assumes ptr is NUL-terminated.  You need to pass size * nmemb
  instead of strlen(accept_line).
 
 OK, the case is so corner, only when :
 - realsize  strlen(accept_line) and
 - ptr is the first part of  accept_line, without NUL-termination
 strncpm will possibly access no more than (strlen(accept_line) -
 realsize) bytes after ptr buffer.
 
 I'll need to check if realsize = strlen(accept_line), not passing realsize.

You can just pass size * nmemb because strncmp() does check for NUL in
both strings.  Therefore strlen(accept_line) is not needed - you know
accept_line is NUL-terminated.

Stefan



Re: [Qemu-devel] [PATCH qom-cpu 31/59] monitor: Simplify do_info_numa()

2013-06-11 Thread Markus Armbruster
Andreas Färber afaer...@suse.de writes:

 Am 10.06.2013 09:20, schrieb Markus Armbruster:
 Andreas Färber afaer...@suse.de writes:
 
 Use new qemu_for_each_cpu().

 Signed-off-by: Andreas Färber afaer...@suse.de
 ---
  monitor.c | 27 +++
  1 file changed, 19 insertions(+), 8 deletions(-)

 diff --git a/monitor.c b/monitor.c
 index 9be515c..f37bf3d 100644
 --- a/monitor.c
 +++ b/monitor.c
 @@ -1803,21 +1803,32 @@ static void do_info_mtree(Monitor *mon, const QDict 
 *qdict)
  mtree_info((fprintf_function)monitor_printf, mon);
  }
  
 +typedef struct DoInfoNUMAData {
 +Monitor *mon;
 +int numa_node;
 +} DoInfoNUMAData;
 +
 +static void do_info_numa_one(CPUState *cpu, void *data)
 +{
 +DoInfoNUMAData *s = data;
 +
 +if (cpu-numa_node == s-numa_node) {
 +monitor_printf(s-mon,  %d, cpu-cpu_index);
 +}
 +}
 +
  static void do_info_numa(Monitor *mon, const QDict *qdict)
  {
  int i;
 -CPUArchState *env;
 -CPUState *cpu;
 +DoInfoNUMAData s = {
 +.mon = mon,
 +};
  
  monitor_printf(mon, %d nodes\n, nb_numa_nodes);
  for (i = 0; i  nb_numa_nodes; i++) {
  monitor_printf(mon, node %d cpus:, i);
 -for (env = first_cpu; env != NULL; env = env-next_cpu) {
 -cpu = ENV_GET_CPU(env);
 -if (cpu-numa_node == i) {
 -monitor_printf(mon,  %d, cpu-cpu_index);
 -}
 -}
 +s.numa_node = i;
 +qemu_for_each_cpu(do_info_numa_one, s);
  monitor_printf(mon, \n);
  monitor_printf(mon, node %d size: % PRId64  MB\n, i,
  node_mem[i]  20);
 
 This again demonstrates the relative clunkiness of higher order
 functions in C.  Control flow jumps back and forth in the source
 (lambda, how I miss you), you need an extra type, and you need to go
 around the type system.
 
 In my experience, loops are a much more natural fit for C.
 
 Would it be possible to have a function cpu_next(CPUState *)?  So you
 can simply do:
 
 for (cpu = cpu_next(NULL); cpu; cpu = cpu_next(cpu) {
 if (cpu-numa_node == i) {
 monitor_printf(mon,  %d, cpu-cpu_index);
 }
 }
 
 Simple and type safe.
 
 Precedence: bdrv_next().

 I can see your point, but I don't like the suggested alternative.

 Are you generally opposed to qemu_for_each_cpu() for iteration?
 http://git.qemu.org/?p=qemu.git;a=commit;h=d6b9e0d60cc511eca210834428bb74508cff3d33

 Or is it just the need to pass in more than one value via struct, as
 done in this patch among others, that you dislike? I.e., are you okay
 with patch 03/59 where each loop iteration is independent?

Dislike is more accurate than oppose.

I dislike the notational overhead and weak typing of higher order
functions in C in general.  The additional type merely adds a little to
the notational overhead.

Higher order functions can still be sensible in C when the iterator has
complex state.  For instance, when the iterator is most easily expressed
as recursive function.

 Before this function came up, I had a macro in mind to abstract the
 loop. Then however I thought such a loop would be duplicating the
 qemu/queue.h macros we already have with their _SAFE_ variants, so I was
 hoping to replace the CPU_COMMON next_cpu field with one of those macros
 in CPUState.

 Unfortunately at least two places did CPUArchState** pointer magic, so
 that I couldn't just change first_cpu and leave next_cpu for later.

I agree that we better not reinvent queue.h.

 Now, I don't see a huge benefit of doing
 for (cpu = cpu_next(NULL); cpu != NULL; cpu = cpu_next(cpu)) {...}
 over
 for (cpu = first_cpu; cpu != NULL; cpu = cpu-next_cpu) {...}
 with the latter being much clearer to read IMO.

You're right.  The iterator is too trivial to warrant encapsulation.
But making the encapsulation less trivial by using a higher order
function doesn't change that one bit :)

What can change it is a desire to make the type of first_cpu abstract,
because then you can't dereference cpu-next_cpu, or a desire to give
first_cpu internal linkage.  That's what motivated bdrv_next().

 If having patch 57/59 larger is not a concern (which getting rid of
 open-coded CPU loops tried to address), then I can just convert the
 loops in place alongside first_cpu / next_cpu.
 Then still the question remains of whether you'd want to inline and drop
 qemu_for_each_cpu() afterwards, or whether we can establish some rules
 of thumb when to use which?

To be honest, I see no value in qemu_for_each_cpu().

At a glance, PATCH 57 looks fairly mechanical to me.  Is it?  Would it
remain so if refrains from converting simple loops to
qemu_for_each_cpu()?



Re: [Qemu-devel] [PATCH] qemu: piix: PCI bridge ACPI hotplug support

2013-06-11 Thread Gerd Hoffmann
  Hi,

 Portability:
 - Non x86 (or any Linux) platforms don't need any of this code.
   They can keep happily using SHPC the way
   they always did.

 Hmm.  Is is possible to write a SHPC driver in AML?  I think it would be
 alot better to have one guest/host interface for pci bridge hotplug
 instead of two.

 cheers,
   Gerd
 
 No, it's not possible, SHPC is not designed to be used from ACPI.
 
 Two reasons off the top of my head, there are likely others:
 
 1. SHPC uses regular PCI interrupts to signal events. It does not signal
GFE and SCI.
 
 2. SHPC uses config accesses to get information from device.
ACPI does not allow config access anywhere except the root bus from ACPI
(This requirement is designed to give the OS freedom
to reconfigure PCI in an arbitrary way).

OK, so it's designed for OSes to have native SHPC support.  Linux has that?

Quick googling found me Windows Vista+ has it too, correct?  So that
leaves Win2k + WinXP versions.  Older Windows versions do not support
pci hotplug at all.  Win2k is EOL already.  WinXP will follow soon.

More users?

/me wonders whenever it is worth hopping through the loops needed to
support ACPI-based hotplug of devices behind bridges in the first place.

cheers,
  Gerd




Re: [Qemu-devel] [PATCH v2 0/9] QMP/HMP: add error reason to open failures

2013-06-11 Thread Stefan Hajnoczi
On Mon, Jun 10, 2013 at 01:02:19PM -0400, Luiz Capitulino wrote:
 I was surprised to find out that we still have old users of
 QERR_OPEN_FILE_FAILED that print errors like:
 
 (qemu) dump-guest-memory -p /lkmads/foo
 Could not open '/lkmads/foo'
 (qemu)
 
 This series converts all those users to a new helper called
 error_setg_file_open(), which adds error reason to open failures:
 
 (qemu) dump-guest-memory -p /sfmdkjf/foo
 Could not open '/sfmdkjf/foo': No such file or directory
 (qemu) 
 
 v2
 
  - bdrv_reopen_prepare(): use generic error message
  - s/error/-ret for bdrv_open() errors
 
 Luiz Capitulino (9):
   error: add error_setg_file_open() helper
   rng-random: use error_setg_file_open()
   block: mirror_complete(): use error_setg_file_open()
   blockdev: use error_setg_file_open()
   cpus: use error_setg_file_open()
   dump: qmp_dump_guest_memory(): use error_setg_file_open()
   savevm: qmp_xen_save_devices_state(): use error_setg_file_open()
   block: bdrv_reopen_prepare(): don't use QERR_OPEN_FILE_FAILED
   qerror: drop QERR_OPEN_FILE_FAILED macro
 
  backends/rng-random.c |  3 +--
  block.c   |  4 ++--
  block/mirror.c|  2 +-
  blockdev.c| 11 +++
  cpus.c|  4 ++--
  dump.c|  2 +-
  include/qapi/error.h  |  5 +
  include/qapi/qmp/qerror.h |  3 ---
  savevm.c  |  2 +-
  util/error.c  |  5 +
  10 files changed, 25 insertions(+), 16 deletions(-)
 
 -- 
 1.8.1.4
 

Reviewed-by: Stefan Hajnoczi stefa...@redhat.com



Re: [Qemu-devel] [PATCH v2 0/9] QMP/HMP: add error reason to open failures

2013-06-11 Thread Stefan Hajnoczi
On Mon, Jun 10, 2013 at 01:02:19PM -0400, Luiz Capitulino wrote:
I should have qualified by Reviewed-by: with reviewed block layer changes.

Stefan



Re: [Qemu-devel] [PATCH] virtio-scsi: forward scsibus for virtio-scsi-pci.

2013-06-11 Thread Michael S. Tsirkin
On Tue, Jun 11, 2013 at 09:32:05AM +0200, Frederic Konrad wrote:
 On 11/06/2013 09:21, Michael S. Tsirkin wrote:
 On Tue, Jun 11, 2013 at 08:43:51AM +0200, Frederic Konrad wrote:
 On 10/06/2013 19:00, Michael S. Tsirkin wrote:
 On Mon, Jun 10, 2013 at 11:53:04AM +0200, fred.kon...@greensocs.com wrote:
 From: KONRAD Frederic fred.kon...@greensocs.com
 
 This fix a bug with scsi hotplug on virtio-scsi-pci:
 
 As virtio-scsi-pci doesn't have any scsi bus, we need to forward 
 scsi-hot-add
 to the virtio-scsi-device plugged on the virtio-bus.
 
 Reported-by: Alexey Kardashevskiy a...@ozlabs.ru
 Signed-off-by: KONRAD Frederic fred.kon...@greensocs.com
 ---
   hw/pci/pci-hotplug.c | 19 +--
   1 file changed, 17 insertions(+), 2 deletions(-)
 
 diff --git a/hw/pci/pci-hotplug.c b/hw/pci/pci-hotplug.c
 index 12287d1..c708752 100644
 --- a/hw/pci/pci-hotplug.c
 +++ b/hw/pci/pci-hotplug.c
 @@ -30,6 +30,8 @@
   #include monitor/monitor.h
   #include hw/scsi/scsi.h
   #include hw/virtio/virtio-blk.h
 +#include hw/virtio/virtio-scsi.h
 +#include hw/virtio/virtio-pci.h
   #include qemu/config-file.h
   #include sysemu/blockdev.h
   #include qapi/error.h
 @@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState 
 *adapter,
   {
   SCSIBus *scsibus;
   SCSIDevice *scsidev;
 +VirtIOPCIProxy *virtio_proxy;
   scsibus = (SCSIBus *)
   object_dynamic_cast(OBJECT(QLIST_FIRST(adapter-child_bus)),
   TYPE_SCSI_BUS);
   if (!scsibus) {
 - error_report(Device is not a SCSI adapter);
 - return -1;
 +/*
 + * Check if the adapter is a virtio-scsi-pci, and forward 
 scsi_hot_add
 + * to the virtio-scsi-device.
 + */
 +if (!object_dynamic_cast(OBJECT(adapter), TYPE_VIRTIO_SCSI_PCI)) 
 {
 +error_report(Device is not a SCSI adapter);
 +return -1;
 +}
 +virtio_proxy = VIRTIO_PCI(adapter);
 +adapter = DEVICE(virtio_proxy-bus.vdev);
 +scsibus = (SCSIBus *)
 +  
 object_dynamic_cast(OBJECT(QLIST_FIRST(adapter-child_bus)),
 +TYPE_SCSI_BUS);
 +assert(scsibus);
   }
   /*
 By the way I really wonder. pci-hotplug.c was supposed to
 be legacy interface.
 Is this the only way to add scsi disks?
 And are other ways broken, too?
 Here you can add scsi disks to a given device.
 I think the other ways add scsi disks to a given bus?
 
 Do you see any other?
 
 Thanks,
 Fred
 I don't know, that's why I'm asking.
 
 If it is, that's crazy. There's no reason for
 it to be tied to pci at all.
 
 The commands in pci-hotplug.c are legacy - they don't support things
 like multi root systems and there's no sane way to make them do it.
 
 Your patch probably makes sense for stable, but for 1.6,
 let's fix this properly.
 
 Ok, what do you propose to fix that properly?

The problem is not your patch, it's that generally
we don't appear have a supported way to add drives to devices.

I think drive_hot_add should first of all stop
calling pci_drive_hot_add unless pci_addr
is specified. Teach it to get device id
instead. Add a QMP interface, not just HMP.
Rename the file from device-hotplug.c 


 
 If we want to keep the behaviour of drive_add command,
 I
 think we have two solutions:
 A/ Change the scsi_hot_add to check if it is a virtio-scsi-pci
 device and take
 virtio-scsi-device's scsi bus.
 B/ Make somehow virtio-scsi-pci having a scsi-bus
 (and the same in virtio-scsi-device).
 
 I chose A because it seems a lot easier. For the moment B seems not
 possible,
 but would it be a cleaner solution? What do you think?
 
 Fred

It sounds cleaner though I'm not sure how to implement this.

 
 -- 
 1.8.1.4



Re: [Qemu-devel] [PATCH v2] curl: Don't set curl options on the handle just before it's going to be deleted.

2013-06-11 Thread Stefan Hajnoczi
On Mon, Jun 10, 2013 at 05:40:15PM +0100, Richard W.M. Jones wrote:
 From: Richard W.M. Jones rjo...@redhat.com
 
 (Found by Kamil Dudka)
 
 Signed-off-by: Richard W.M. Jones rjo...@redhat.com
 Cc: Michael Tokarev m...@tls.msk.ru
 ---
  block/curl.c | 2 --
  1 file changed, 2 deletions(-)

Acked-by: Stefan Hajnoczi stefa...@redhat.com



Re: [Qemu-devel] [PATCH] qemu: piix: PCI bridge ACPI hotplug support

2013-06-11 Thread Michael S. Tsirkin
On Tue, Jun 11, 2013 at 09:42:29AM +0200, Gerd Hoffmann wrote:
   Hi,
 
  Portability:
  - Non x86 (or any Linux) platforms don't need any of this code.
They can keep happily using SHPC the way
they always did.
 
  Hmm.  Is is possible to write a SHPC driver in AML?  I think it would be
  alot better to have one guest/host interface for pci bridge hotplug
  instead of two.
 
  cheers,
Gerd
  
  No, it's not possible, SHPC is not designed to be used from ACPI.
  
  Two reasons off the top of my head, there are likely others:
  
  1. SHPC uses regular PCI interrupts to signal events. It does not signal
 GFE and SCI.
  
  2. SHPC uses config accesses to get information from device.
 ACPI does not allow config access anywhere except the root bus from ACPI
 (This requirement is designed to give the OS freedom
 to reconfigure PCI in an arbitrary way).
 
 OK, so it's designed for OSes to have native SHPC support.  Linux has that?

Yes.

 Quick googling found me Windows Vista+ has it too, correct?  So that
 leaves Win2k + WinXP versions.  Older Windows versions do not support
 pci hotplug at all.  Win2k is EOL already.  WinXP will follow soon.
 
 More users?

googling lead you astray.
No windows version supports SHPC.

 /me wonders whenever it is worth hopping through the loops needed to
 support ACPI-based hotplug of devices behind bridges in the first place.
 
 cheers,
   Gerd

Yes and not just because of windows guests.
ACPI spec is also very explicit that native hotplug is an optional
feature. Test suites such as WHQL are known to test spec compliance.

-- 
MST



Re: [Qemu-devel] [PATCH] qemu: piix: PCI bridge ACPI hotplug support

2013-06-11 Thread Gerd Hoffmann
  Hi,

 Yes and not just because of windows guests.
 ACPI spec is also very explicit that native hotplug is an optional
 feature. Test suites such as WHQL are known to test spec compliance.

/me looks a bit surprised.

This pretty much implies that any shpc bridge needs a second interface
to the hotplug functionality which can be driven via ACPI.  Or the
firmware somehow handles this using smm (not sure this works for the IRQ
though).

Do you know how this is handled by real hardware?

cheers,
  Gerd




Re: [Qemu-devel] [PATCH qom-cpu v4 07/18] cpu: Turn cpu_paging_enabled() into a CPUState hook

2013-06-11 Thread Jens Freimann
On Sun, Jun 09, 2013 at 06:10:36PM +0200, Andreas Färber wrote:
 Relocate assignment of x86 get_arch_id to have all hooks in one place.
 
 Signed-off-by: Andreas Färber afaer...@suse.de

Reviewed-by: Jens Freimann jf...@linux.vnet.ibm.com

 ---
  include/qom/cpu.h | 10 ++
  include/sysemu/memory_mapping.h   |  1 -
  memory_mapping-stub.c |  6 --
  memory_mapping.c  |  2 +-
  qom/cpu.c | 13 +
  target-i386/arch_memory_mapping.c |  6 +-
  target-i386/cpu.c | 11 +--
  7 files changed, 34 insertions(+), 15 deletions(-)
 
 diff --git a/include/qom/cpu.h b/include/qom/cpu.h
 index 7cd9442..1f70240 100644
 --- a/include/qom/cpu.h
 +++ b/include/qom/cpu.h
 @@ -48,6 +48,7 @@ typedef struct CPUState CPUState;
   * @reset: Callback to reset the #CPUState to its initial state.
   * @do_interrupt: Callback for interrupt handling.
   * @get_arch_id: Callback for getting architecture-dependent CPU ID.
 + * @get_paging_enabled: Callback for inquiring whether paging is enabled.
   * @vmsd: State description for migration.
   *
   * Represents a CPU family or model.
 @@ -62,6 +63,7 @@ typedef struct CPUClass {
  void (*reset)(CPUState *cpu);
  void (*do_interrupt)(CPUState *cpu);
  int64_t (*get_arch_id)(CPUState *cpu);
 +bool (*get_paging_enabled)(const CPUState *cpu);
  
  const struct VMStateDescription *vmsd;
  int (*write_elf64_note)(WriteCoreDumpFunction f, CPUState *cpu,
 @@ -138,6 +140,14 @@ struct CPUState {
  };
  
  /**
 + * cpu_paging_enabled:
 + * @cpu: The CPU whose state is to be inspected.
 + *
 + * Returns: %true if paging is enabled, %false otherwise.
 + */
 +bool cpu_paging_enabled(const CPUState *cpu);
 +
 +/**
   * cpu_write_elf64_note:
   * @f: pointer to a function that writes memory to a file
   * @cpu: The CPU whose memory is to be dumped
 diff --git a/include/sysemu/memory_mapping.h b/include/sysemu/memory_mapping.h
 index 1256125..6f01524 100644
 --- a/include/sysemu/memory_mapping.h
 +++ b/include/sysemu/memory_mapping.h
 @@ -31,7 +31,6 @@ typedef struct MemoryMappingList {
  } MemoryMappingList;
  
  int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env);
 -bool cpu_paging_enabled(CPUArchState *env);
  
  /*
   * add or merge the memory region [phys_addr, phys_addr + length) into the
 diff --git a/memory_mapping-stub.c b/memory_mapping-stub.c
 index 24d5d67..6c0dfeb 100644
 --- a/memory_mapping-stub.c
 +++ b/memory_mapping-stub.c
 @@ -25,9 +25,3 @@ int cpu_get_memory_mapping(MemoryMappingList *list,
  {
  return -1;
  }
 -
 -bool cpu_paging_enabled(CPUArchState *env)
 -{
 -return true;
 -}
 -
 diff --git a/memory_mapping.c b/memory_mapping.c
 index ff45b3a..0790aac 100644
 --- a/memory_mapping.c
 +++ b/memory_mapping.c
 @@ -170,7 +170,7 @@ static CPUArchState *find_paging_enabled_cpu(CPUArchState 
 *start_cpu)
  CPUArchState *env;
  
  for (env = start_cpu; env != NULL; env = env-next_cpu) {
 -if (cpu_paging_enabled(env)) {
 +if (cpu_paging_enabled(ENV_GET_CPU(env))) {
  return env;
  }
  }
 diff --git a/qom/cpu.c b/qom/cpu.c
 index 04aefbb..9f6da0f 100644
 --- a/qom/cpu.c
 +++ b/qom/cpu.c
 @@ -50,6 +50,18 @@ bool cpu_exists(int64_t id)
  return data.found;
  }
  
 +bool cpu_paging_enabled(const CPUState *cpu)
 +{
 +CPUClass *cc = CPU_GET_CLASS(cpu);
 +
 +return cc-get_paging_enabled(cpu);
 +}
 +
 +static bool cpu_common_get_paging_enabled(const CPUState *cpu)
 +{
 +return true;
 +}
 +
  /* CPU hot-plug notifiers */
  static NotifierList cpu_added_notifiers =
  NOTIFIER_LIST_INITIALIZER(cpu_add_notifiers);
 @@ -176,6 +188,7 @@ static void cpu_class_init(ObjectClass *klass, void *data)
  k-class_by_name = cpu_common_class_by_name;
  k-reset = cpu_common_reset;
  k-get_arch_id = cpu_common_get_arch_id;
 +k-get_paging_enabled = cpu_common_get_paging_enabled;
  k-write_elf32_qemunote = cpu_common_write_elf32_qemunote;
  k-write_elf32_note = cpu_common_write_elf32_note;
  k-write_elf64_qemunote = cpu_common_write_elf64_qemunote;
 diff --git a/target-i386/arch_memory_mapping.c 
 b/target-i386/arch_memory_mapping.c
 index 5096fbd..c5a10ec 100644
 --- a/target-i386/arch_memory_mapping.c
 +++ b/target-i386/arch_memory_mapping.c
 @@ -241,7 +241,7 @@ static void walk_pml4e(MemoryMappingList *list,
  
  int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env)
  {
 -if (!cpu_paging_enabled(env)) {
 +if (!cpu_paging_enabled(ENV_GET_CPU(env))) {
  /* paging is disabled */
  return 0;
  }
 @@ -273,7 +273,3 @@ int cpu_get_memory_mapping(MemoryMappingList *list, 
 CPUArchState *env)
  return 0;
  }
  
 -bool cpu_paging_enabled(CPUArchState *env)
 -{
 -return env-cr[0]  CR0_PG_MASK;
 -}
 diff --git a/target-i386/cpu.c b/target-i386/cpu.c
 index 4b2da0d..f6fa7fa 100644
 --- a/target-i386/cpu.c
 +++ 

[Qemu-devel] [PATCH 0/1] TCG Aarch64 ldst 12bit scaled uimm

2013-06-11 Thread Claudio Fontana

Using only the ldst simm9 (unscaled offset) will often result in the
fallback mov immediate + ldst (register offset) to be triggered.

This change implements the ldst uimm12 (scaled offset), which avoids
the expensive fallback in certain conditions: the offset must be
naturally aligned and positive, and the scaled value must be
representable with 12bits.

This patch requires multiple reviewed but not committed yet series
reachable from:

https://lists.gnu.org/archive/html/qemu-devel/2013-06/msg00880.html
AArch64 TCG target implementation, git repo

Claudio Fontana (1):
  tcg/aarch64: implement ldst 12bit scaled uimm offset

 tcg/aarch64/tcg-target.c | 32 +---
 1 file changed, 29 insertions(+), 3 deletions(-)

-- 
1.8.1





[Qemu-devel] [PATCH 1/1] tcg/aarch64: implement ldst 12bit scaled uimm offset

2013-06-11 Thread Claudio Fontana

implement the 12bit scaled unsigned immediate offset
variant of LDR/STR. This improves code size by avoiding
the movi + ldst_r for naturally aligned offsets in range.

Signed-off-by: Claudio Fontana claudio.font...@huawei.com
---
 tcg/aarch64/tcg-target.c | 32 +---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/tcg/aarch64/tcg-target.c b/tcg/aarch64/tcg-target.c
index 8bb195e..96e8538 100644
--- a/tcg/aarch64/tcg-target.c
+++ b/tcg/aarch64/tcg-target.c
@@ -315,6 +315,17 @@ static inline void tcg_out_ldst_9(TCGContext *s,
 tcg_out32(s, op_data  24 | mod  20 | off  12 | rn  5 | rd);
 }
 
+/* tcg_out_ldst_12 expects a scaled unsigned immediate offset */
+static inline void tcg_out_ldst_12(TCGContext *s,
+   enum aarch64_ldst_op_data op_data,
+   enum aarch64_ldst_op_type op_type,
+   TCGReg rd, TCGReg rn,
+   tcg_target_ulong scaled_uimm)
+{
+tcg_out32(s, (op_data | 1)  24
+  | op_type  20 | scaled_uimm  10 | rn  5 | rd);
+}
+
 static inline void tcg_out_movr(TCGContext *s, int ext, TCGReg rd, TCGReg src)
 {
 /* register to register move using MOV (shifted register with no shift) */
@@ -374,10 +385,25 @@ static inline void tcg_out_ldst(TCGContext *s, enum 
aarch64_ldst_op_data data,
 {
 if (offset = -256  offset  256) {
 tcg_out_ldst_9(s, data, type, rd, rn, offset);
-} else {
-tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP, offset);
-tcg_out_ldst_r(s, data, type, rd, rn, TCG_REG_TMP);
+return;
 }
+
+if (offset = 256) {
+/* if the offset is naturally aligned and in range,
+   then we can use the scaled uimm12 encoding */
+unsigned int s_bits = data  6;
+if (!(offset  ((1  s_bits) - 1))) {
+tcg_target_ulong scaled_uimm = offset  s_bits;
+if (scaled_uimm = 0xfff) {
+tcg_out_ldst_12(s, data, type, rd, rn, scaled_uimm);
+return;
+}
+}
+}
+
+/* worst-case scenario, move offset to temp register, use reg offset */
+tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP, offset);
+tcg_out_ldst_r(s, data, type, rd, rn, TCG_REG_TMP);
 }
 
 /* mov alias implemented with add immediate, useful to move to/from SP */
-- 
1.8.1





Re: [Qemu-devel] [PATCH] qemu: piix: PCI bridge ACPI hotplug support

2013-06-11 Thread Michael S. Tsirkin
On Tue, Jun 11, 2013 at 10:00:36AM +0200, Gerd Hoffmann wrote:
   Hi,
 
  Yes and not just because of windows guests.
  ACPI spec is also very explicit that native hotplug is an optional
  feature. Test suites such as WHQL are known to test spec compliance.
 
 /me looks a bit surprised.
 
 This pretty much implies that any shpc bridge needs a second interface
 to the hotplug functionality which can be driven via ACPI.  Or the
 firmware somehow handles this using smm (not sure this works for the IRQ
 though).
 
 Do you know how this is handled by real hardware?
 
 cheers,
   Gerd

SHPC is not very widely deployed on a PC.

Since most hardware vendors do care about windows support,
the only way is a separate interface that is driven via ACPI.
You then need an ACPI specific register to switch to standard SHPC.
The SHPC spec even tells you as much.

-- 
MST



Re: [Qemu-devel] [PATCH] curl: refuse to open URL from HTTP server without range support

2013-06-11 Thread Kevin Wolf
Am 11.06.2013 um 09:40 hat Stefan Hajnoczi geschrieben:
 On Tue, Jun 11, 2013 at 11:15:15AM +0800, Fam Zheng wrote:
  On Mon, Jun 10, 2013 at 5:21 PM, Stefan Hajnoczi stefa...@gmail.com wrote:
   On Sun, Jun 09, 2013 at 10:34:54AM +0800, Fam Zheng wrote:
   @@ -110,14 +111,14 @@ static int curl_sock_cb(CURL *curl, curl_socket_t 
   fd, int action,
return 0;
}
  
   -static size_t curl_size_cb(void *ptr, size_t size, size_t nmemb, void 
   *opaque)
   +static size_t curl_header_cb(void *ptr, size_t size, size_t nmemb, void 
   *opaque)
{
   -CURLState *s = ((CURLState*)opaque);
   +BDRVCURLState *s = opaque;
size_t realsize = size * nmemb;
   -size_t fsize;
   +const char *accept_line = Accept-Ranges: bytes;
  
   -if(sscanf(ptr, Content-Length: %zd, fsize) == 1) {
   -s-s-len = fsize;
   +if (strncmp((char *)ptr, accept_line, strlen(accept_line)) == 0) {
   +s-accept_range = true;
}
  
   This still assumes ptr is NUL-terminated.  You need to pass size * nmemb
   instead of strlen(accept_line).
  
  OK, the case is so corner, only when :
  - realsize  strlen(accept_line) and
  - ptr is the first part of  accept_line, without NUL-termination
  strncpm will possibly access no more than (strlen(accept_line) -
  realsize) bytes after ptr buffer.
  
  I'll need to check if realsize = strlen(accept_line), not passing realsize.
 
 You can just pass size * nmemb because strncmp() does check for NUL in
 both strings.  Therefore strlen(accept_line) is not needed - you know
 accept_line is NUL-terminated.

Don't you just want to check that ptr _starts_ with accept_line rather
than requiring an exact match?

Kevin



Re: [Qemu-devel] [PATCH v2] curl: Don't set curl options on the handle just before it's going to be deleted.

2013-06-11 Thread Kevin Wolf
Am 10.06.2013 um 18:40 hat Richard W.M. Jones geschrieben:
 From: Richard W.M. Jones rjo...@redhat.com
 
 (Found by Kamil Dudka)
 
 Signed-off-by: Richard W.M. Jones rjo...@redhat.com
 Cc: Michael Tokarev m...@tls.msk.ru

Thanks, applied to the block branch.

Kevin



Re: [Qemu-devel] [PATCH 04/11] snapshot: new function bdrv_snapshot_find_by_id_and_name()

2013-06-11 Thread Stefan Hajnoczi
On Sat, Jun 08, 2013 at 02:58:00PM +0800, Wenchao Xia wrote:
 +if (id  name) {
 +for (i = 0; i  nb_sns; i++) {
 +sn = sn_tab[i];
 +if (!strcmp(sn-id_str, id)  !strcmp(sn-name, name)) {
 +*sn_info = *sn;
 +ret = true;
 +break;
 +}
 +}
 +} else if (id) {
 +for (i = 0; i  nb_sns; i++) {
 +sn = sn_tab[i];
 +if (!strcmp(sn-id_str, id)) {
 +*sn_info = *sn;
 +ret = true;
 +break;
 +}
 +}
 +} else if (name) {
 +for (i = 0; i  nb_sns; i++) {
 +sn = sn_tab[i];
 +if (!strcmp(sn-name, name)) {
 +*sn_info = *sn;
 +ret = true;
 +break;
 +}
 +}
 +} else {
 +/* program error */
 +abort();
 +}

If you respin, this would be a little clearer:

assert(id || name);

if (id  name) {
...
} else if (id) {
...
} else if (name) {
...
}

The advantage is that the assert(3) condition is included in the error
message that gets printed.

Stefan



Re: [Qemu-devel] [PATCH] qemu: piix: PCI bridge ACPI hotplug support

2013-06-11 Thread Michael S. Tsirkin
On Tue, Jun 11, 2013 at 11:18:13AM +0300, Michael S. Tsirkin wrote:
 On Tue, Jun 11, 2013 at 10:00:36AM +0200, Gerd Hoffmann wrote:
Hi,
  
   Yes and not just because of windows guests.
   ACPI spec is also very explicit that native hotplug is an optional
   feature. Test suites such as WHQL are known to test spec compliance.
  
  /me looks a bit surprised.
  
  This pretty much implies that any shpc bridge needs a second interface
  to the hotplug functionality which can be driven via ACPI.  Or the
  firmware somehow handles this using smm (not sure this works for the IRQ
  though).
  
  Do you know how this is handled by real hardware?
  
  cheers,
Gerd
 
 SHPC is not very widely deployed on a PC.
 
 Since most hardware vendors do care about windows support,
 the only way is a separate interface that is driven via ACPI.
 You then need an ACPI specific register to switch to standard SHPC.
 The SHPC spec even tells you as much.

Just to give another example, interface in this patch
scales trivially to multi-root configurations,
if we ever want to support them.

 -- 
 MST



Re: [Qemu-devel] [PATCH 8/9] block: bdrv_reopen_prepare(): don't use QERR_OPEN_FILE_FAILED

2013-06-11 Thread Kevin Wolf
Am 10.06.2013 um 19:02 hat Luiz Capitulino geschrieben:
 The call to drv-bdrv_reopen_prepare() can fail due to reasons
 other than an open failure. Unfortunately, we can't use errno
 nor -ret, cause they are not always set.
 
 Stick to a generic error message then.
 
 Signed-off-by: Luiz Capitulino lcapitul...@redhat.com
 ---
  block.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/block.c b/block.c
 index 79ad33d..b88ad2f 100644
 --- a/block.c
 +++ b/block.c
 @@ -1291,8 +1291,8 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, 
 BlockReopenQueue *queue,
  if (local_err != NULL) {
  error_propagate(errp, local_err);
  } else {
 -error_set(errp, QERR_OPEN_FILE_FAILED,
 -  reopen_state-bs-filename);
 +error_setg(errp, failed while preparing to reopen image 
 '%s',

Please start the message with an uppercase letter like before.

Also, maybe Failed to prepare for reopening '%s' is better?

 +   reopen_state-bs-filename);
  }
  goto error;
  }

Kevin



Re: [Qemu-devel] [PATCH v2 0/9] QMP/HMP: add error reason to open failures

2013-06-11 Thread Kevin Wolf
Am 10.06.2013 um 19:02 hat Luiz Capitulino geschrieben:
 I was surprised to find out that we still have old users of
 QERR_OPEN_FILE_FAILED that print errors like:
 
 (qemu) dump-guest-memory -p /lkmads/foo
 Could not open '/lkmads/foo'
 (qemu)
 
 This series converts all those users to a new helper called
 error_setg_file_open(), which adds error reason to open failures:
 
 (qemu) dump-guest-memory -p /sfmdkjf/foo
 Could not open '/sfmdkjf/foo': No such file or directory
 (qemu) 
 
 v2
 
  - bdrv_reopen_prepare(): use generic error message
  - s/error/-ret for bdrv_open() errors

I suggested an error message change in patch 8, but I think that's minor
enough that you don't have to resend the series after changing the text.
So you can add:

Acked-by: Kevin Wolf kw...@redhat.com



Re: [Qemu-devel] [PATCH] Unbreak -no-quit for GTK when SDL is disabled

2013-06-11 Thread Peter Wu
On Monday 10 June 2013 16:53:06 Anthony Liguori wrote:
 Peter Wu lekenst...@gmail.com writes:
  When QEMU is built without SDL support, -no-quit would print an error
  message that SDL is disabled. Since GTK also supports -no-quit, enable
  the option when GTK or SDL is enabled at compile time.
  
  While at it, do not create the no_quit variable when it is not used.
  
  Signed-off-by: Peter Wu lekenst...@gmail.com
 
 Any harm in just making -no-quit unconditional?

No harm, there are just 4 bytes more memory wasted and some code, not a big 
deal.

 It's a nop for VNC and presumably for spice too but it's not incorrect
 AFAICT.
 
 Would be nice to drop #ifdefs if we can.

The readability should increase by dropping it. By the way, this integer 
should really be a bool.

As shortly discussed on IRC, a better approach is testing for the sanity of 
certain usages instead of ifdef'ing stuff. Having SDL compiled in and then 
using VNC still does not make -alt-grab more valid.

Let's drop this patch, I will submit a new one which checks the option at run-
time.

Regards,
Peter

 Regards,
 
 Anthony Liguori
 
  ---
  
   include/sysemu/sysemu.h |  2 ++
   vl.c| 13 +
   2 files changed, 11 insertions(+), 4 deletions(-)
  
  diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
  index 2fb71af..b9b8e52 100644
  --- a/include/sysemu/sysemu.h
  +++ b/include/sysemu/sysemu.h
  @@ -117,7 +117,9 @@ extern int smp_cpus;
  
   extern int max_cpus;
   extern int cursor_hide;
   extern int graphic_rotate;
  
  +#if defined(CONFIG_SDL) || defined(CONFIG_GTK)
  
   extern int no_quit;
  
  +#endif
  
   extern int no_shutdown;
   extern int semihosting_enabled;
   extern int old_param;
  
  diff --git a/vl.c b/vl.c
  index cfd2d3e..74ab050 100644
  --- a/vl.c
  +++ b/vl.c
  @@ -202,7 +202,9 @@ static int full_screen = 0;
  
   #ifdef CONFIG_SDL
   static int no_frame = 0;
   #endif
  
  +#if defined(CONFIG_SDL) || defined(CONFIG_GTK)
  
   int no_quit = 0;
  
  +#endif
  
   CharDriverState *serial_hds[MAX_SERIAL_PORTS];
   CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
   CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES];
  
  @@ -3523,6 +3525,13 @@ int main(int argc, char **argv, char **envp)
  
   case QEMU_OPTION_full_screen:
   full_screen = 1;
   break;
  
  +case QEMU_OPTION_no_quit:
  +#if defined(CONFIG_SDL) || defined(CONFIG_GTK)
  +no_quit = 1;
  +#else
  +fprintf(stderr, SDL and GTK support are disabled\n);
  +#endif
  +break;
  
   #ifdef CONFIG_SDL
   
   case QEMU_OPTION_no_frame:
   no_frame = 1;
  
  @@ -3533,9 +3542,6 @@ int main(int argc, char **argv, char **envp)
  
   case QEMU_OPTION_ctrl_grab:
   ctrl_grab = 1;
   break;
  
  -case QEMU_OPTION_no_quit:
  -no_quit = 1;
  -break;
  
   case QEMU_OPTION_sdl:
   display_type = DT_SDL;
   break;
  
  @@ -3543,7 +3549,6 @@ int main(int argc, char **argv, char **envp)
  
   case QEMU_OPTION_no_frame:
   case QEMU_OPTION_alt_grab:
  
   case QEMU_OPTION_ctrl_grab:
  -case QEMU_OPTION_no_quit:
   case QEMU_OPTION_sdl:
   fprintf(stderr, SDL support is disabled\n);
   exit(1);



[Qemu-devel] [PATCH] Unbreak -no-quit for GTK, validate SDL options

2013-06-11 Thread Peter Wu
Certain options (-no-frame, -alt-grab, -ctrl-grab) only make sense with SDL.
When compiling without SDL, these options (and -no-quit) print an error message
and exit qemu.

In case QEMU is compiled with SDL support, the three aforementioned options
still do not make sense with other display types. This patch addresses that
issue by printing a warning. I have chosen not to exit QEMU afterwards because
having the option is not harmful and before this patch it would be ignored
anyway.

By delaying the sanity check from compile-time with some ifdefs to run-time,
-no-quit is now also properly supported when compiling without SDL.

Signed-off-by: Peter Wu lekenst...@gmail.com
---
 vl.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/vl.c b/vl.c
index cfd2d3e..29ab85c 100644
--- a/vl.c
+++ b/vl.c
@@ -3523,7 +3523,6 @@ int main(int argc, char **argv, char **envp)
 case QEMU_OPTION_full_screen:
 full_screen = 1;
 break;
-#ifdef CONFIG_SDL
 case QEMU_OPTION_no_frame:
 no_frame = 1;
 break;
@@ -3536,14 +3535,11 @@ int main(int argc, char **argv, char **envp)
 case QEMU_OPTION_no_quit:
 no_quit = 1;
 break;
+#ifdef CONFIG_SDL
 case QEMU_OPTION_sdl:
 display_type = DT_SDL;
 break;
 #else
-case QEMU_OPTION_no_frame:
-case QEMU_OPTION_alt_grab:
-case QEMU_OPTION_ctrl_grab:
-case QEMU_OPTION_no_quit:
 case QEMU_OPTION_sdl:
 fprintf(stderr, SDL support is disabled\n);
 exit(1);
@@ -4084,6 +4080,15 @@ int main(int argc, char **argv, char **envp)
 #endif
 }
 
+if ((no_frame || alt_grab || ctrl_grab)  display_type != DT_SDL) {
+fprintf(stderr, -no-frame, -alt-grab and -ctrl-grab are only valid 
+for SDL, ignoring option\n);
+}
+if (no_quit  (display_type != DT_GTK  display_type != DT_SDL)) {
+fprintf(stderr, -no-quit is only valid for GTK and SDL, 
+ignoring option\n);
+}
+
 #if defined(CONFIG_GTK)
 if (display_type == DT_GTK) {
 early_gtk_display_init();
-- 
1.8.3




Re: [Qemu-devel] [PATCH qom-cpu v4 12/18] cpu: Change default for CPUClass::get_paging_enabled()

2013-06-11 Thread Jens Freimann
On Sun, Jun 09, 2013 at 06:10:41PM +0200, Andreas Färber wrote:
 qemu_get_guest_memory_mapping() uses cpu_paging_enabled() to determine
 whether to use cpu_get_memory_mapping() to return mappings or whether to
 fall back to a simple identity map.
 
 Since by default CPUClass::get_memory_mapping() is not implemented,
 change the default to false to use the identity map by default.
 
 Signed-off-by: Andreas Färber afaer...@suse.de

Reviewed-by: Jens Freimann jf...@linux.vnet.ibm.com 

 ---
  qom/cpu.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/qom/cpu.c b/qom/cpu.c
 index b25fbc9..dba4a11 100644
 --- a/qom/cpu.c
 +++ b/qom/cpu.c
 @@ -59,7 +59,7 @@ bool cpu_paging_enabled(const CPUState *cpu)
  
  static bool cpu_common_get_paging_enabled(const CPUState *cpu)
  {
 -return true;
 +return false;
  }
  
  void cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list,
 -- 
 1.8.1.4
 
 




Re: [Qemu-devel] [Qemu-trivial] [PATCH v1 1/5] intc/xilinx_intc: Use qemu_set_irq

2013-06-11 Thread Michael Tokarev
11.06.2013 04:41, Peter Crosthwaite wrote:
 On Sat, Jun 8, 2013 at 8:36 AM, Michael Tokarev m...@tls.msk.ru wrote:
 Thanks, applied to the trivial patches queue.
 
 I need to respin the later patches in this series but as you have
 taken this ill drop it from the respin. No conflict issues.

heh.  I haven't even noticed this is 1/5 ;)

Please don't send just some patches from a series
for applying to other trees.  Because if you do
the respin, at least in some cases you'll have to wait
for the applied bits to reach master first... ;)

It's as trivial to remove this one from -trivial as
to keep it there, it's your call ;)

Thanks,

/mjt



Re: [Qemu-devel] [PATCH 05/11] snapshot: add paired functions for internal snapshot id and name

2013-06-11 Thread Stefan Hajnoczi
On Sat, Jun 08, 2013 at 02:58:01PM +0800, Wenchao Xia wrote:
 +/*
 + * Every internal snapshot have an ID used by qemu block layer, this function
 + * check whether name used by user mess up with ID. An empty string is also
 + * invalid.
 + */
 +bool snapshot_name_wellformed(const char *name)
 +{
 +char *p;
 +/* variable v is used to remove gcc warning of ignoring return value 
 and
 +   set but not used */
 +unsigned long v;
 +
 +if (*name == '\0') {
 +return false;
 +}
 +
 +v = strtoul(name, p, 10);
 +v++;
 +
 +if (*p == '\0') {
 +/* Numeric string */
 +return false;
 +}
 +return true;
 +}

Shorter function with the same behavior and a rewritten doc comment:

/*
 * Return true if the given internal snapshot name is valid, false
 * otherwise.
 *
 * To prevent clashes with internal snapshot IDs, names consisting only
 * of digits are rejected.  Empty strings are also rejected.
 */
bool snapshot_name_wellformed(const char *name)
{
return strspn(name, 0123456789) != strlen(name);
}

 +
 +/* Following function generate id string, used by block driver, such as 
 qcow2.
 +   Since no better place to go, place the funtion here for now. */
 +void snapshot_id_string_generate(int id, char *id_str, int id_str_size)
 +{
 +snprintf(id_str, id_str_size, %d, id);
 +}

Since the caller has to manage id, this function doesn't really abstract
anything.  I would keep the snprintf() inline, there's only one caller.



Re: [Qemu-devel] [PATCH qom-cpu v4 09/18] cpu: Turn cpu_get_memory_mapping() into a CPUState hook

2013-06-11 Thread Jens Freimann
On Sun, Jun 09, 2013 at 06:10:38PM +0200, Andreas Färber wrote:
 Change error reporting from return value to Error argument.
 
 Signed-off-by: Andreas Färber afaer...@suse.de

Reviewd-by: Jens Freimann jf...@linux.vnet.ibm.com

 ---
  include/qom/cpu.h | 14 ++
  include/sysemu/memory_mapping.h   |  2 --
  memory_mapping-stub.c |  6 --
  memory_mapping.c  |  7 ---
  qom/cpu.c | 16 
  target-i386/arch_memory_mapping.c | 12 +++-
  target-i386/cpu-qom.h |  3 +++
  target-i386/cpu.c |  1 +
  8 files changed, 45 insertions(+), 16 deletions(-)
 
 diff --git a/include/qom/cpu.h b/include/qom/cpu.h
 index 1f70240..254be2e 100644
 --- a/include/qom/cpu.h
 +++ b/include/qom/cpu.h
 @@ -23,6 +23,7 @@
  #include signal.h
  #include hw/qdev-core.h
  #include qemu/thread.h
 +#include qemu/typedefs.h
  
  typedef int (*WriteCoreDumpFunction)(void *buf, size_t size, void *opaque);
  
 @@ -49,6 +50,7 @@ typedef struct CPUState CPUState;
   * @do_interrupt: Callback for interrupt handling.
   * @get_arch_id: Callback for getting architecture-dependent CPU ID.
   * @get_paging_enabled: Callback for inquiring whether paging is enabled.
 + * @get_memory_mapping: Callback for obtaining the memory mappings.
   * @vmsd: State description for migration.
   *
   * Represents a CPU family or model.
 @@ -64,6 +66,8 @@ typedef struct CPUClass {
  void (*do_interrupt)(CPUState *cpu);
  int64_t (*get_arch_id)(CPUState *cpu);
  bool (*get_paging_enabled)(const CPUState *cpu);
 +void (*get_memory_mapping)(CPUState *cpu, MemoryMappingList *list,
 +   Error **errp);
  
  const struct VMStateDescription *vmsd;
  int (*write_elf64_note)(WriteCoreDumpFunction f, CPUState *cpu,
 @@ -148,6 +152,16 @@ struct CPUState {
  bool cpu_paging_enabled(const CPUState *cpu);
  
  /**
 + * @cpu: The CPU whose memory mappings are to be obtained.
 + * @list: Where to write the memory mappings to.
 + * @errp: Pointer for reporting an #Error.
 + *
 + * Returns: 0 if successful.
 + */
 +void cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list,
 +Error **errp);
 +
 +/**
   * cpu_write_elf64_note:
   * @f: pointer to a function that writes memory to a file
   * @cpu: The CPU whose memory is to be dumped
 diff --git a/include/sysemu/memory_mapping.h b/include/sysemu/memory_mapping.h
 index 1f71c32..c47e6ee 100644
 --- a/include/sysemu/memory_mapping.h
 +++ b/include/sysemu/memory_mapping.h
 @@ -31,8 +31,6 @@ struct MemoryMappingList {
  QTAILQ_HEAD(, MemoryMapping) head;
  };
  
 -int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env);
 -
  /*
   * add or merge the memory region [phys_addr, phys_addr + length) into the
   * memory mapping's list. The region's virtual address starts with virt_addr,
 diff --git a/memory_mapping-stub.c b/memory_mapping-stub.c
 index 6c0dfeb..989dc00 100644
 --- a/memory_mapping-stub.c
 +++ b/memory_mapping-stub.c
 @@ -19,9 +19,3 @@ int qemu_get_guest_memory_mapping(MemoryMappingList *list)
  {
  return -2;
  }
 -
 -int cpu_get_memory_mapping(MemoryMappingList *list,
 - 
   CPUArchState *env)
 -{
 -return -1;
 -}
 diff --git a/memory_mapping.c b/memory_mapping.c
 index 0790aac..9bd24ce 100644
 --- a/memory_mapping.c
 +++ b/memory_mapping.c
 @@ -183,13 +183,14 @@ int qemu_get_guest_memory_mapping(MemoryMappingList 
 *list)
  CPUArchState *env, *first_paging_enabled_cpu;
  RAMBlock *block;
  ram_addr_t offset, length;
 -int ret;
  
  first_paging_enabled_cpu = find_paging_enabled_cpu(first_cpu);
  if (first_paging_enabled_cpu) {
  for (env = first_paging_enabled_cpu; env != NULL; env = 
 env-next_cpu) {
 -ret = cpu_get_memory_mapping(list, env);
 -if (ret  0) {
 +Error *err = NULL;
 +cpu_get_memory_mapping(ENV_GET_CPU(env), list, err);
 +if (err) {
 +error_free(err);
  return -1;
  }
  }
 diff --git a/qom/cpu.c b/qom/cpu.c
 index 9f6da0f..b25fbc9 100644
 --- a/qom/cpu.c
 +++ b/qom/cpu.c
 @@ -62,6 +62,21 @@ static bool cpu_common_get_paging_enabled(const CPUState 
 *cpu)
  return true;
  }
  
 +void cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list,
 +Error **errp)
 +{
 +CPUClass *cc = CPU_GET_CLASS(cpu);
 +
 +return cc-get_memory_mapping(cpu, list, errp);
 +}
 +
 +static void cpu_common_get_memory_mapping(CPUState *cpu,
 +  MemoryMappingList *list,
 +  Error **errp)
 +{
 +error_setg(errp, Obtaining memory mappings is unsupported on this 
 CPU.);
 +}
 +
  /* CPU hot-plug notifiers */
  static NotifierList cpu_added_notifiers =
  

Re: [Qemu-devel] [PATCH trivial] configure: explicitly disable virtfs if softmmu=no

2013-06-11 Thread M. Mohan Kumar
Michael Tokarev m...@tls.msk.ru writes:

 11.06.2013 00:47, Michael Tokarev wrote:
 Or else
 
  ./configure --disable-system --enable-virtfs
 
 (which makes no sense by its own but does not error out)
 will fail to build, because it will define CONFIG_VIRTFS,
 and the makefile will try to build virtfs-proxy-helper
 manpage (but not the executable).

 The build fails in this case in a separate build tree, because
 the fsdev directory is not created and scripts/texi2pod.pl
 will be called with output = fsdev/virtfs-proxy-helper.pod,
 which can't be created because fsdev/ does not exist.


Hi,

I tried ./configure --disable-system --enable-virtfs and make. But didnt
face any build failure. Could you please share your build failure
information? virtfs-proxy-helper.1 is created inside the fsdev folder.

 
 Cc: qemu-triv...@nongnu.org
 Cc: M. Mohan Kumar mo...@in.ibm.com
 Signed-off-by: Michael Tokarev m...@tls.msk.ru
 ---
  configure |2 ++
  1 file changed, 2 insertions(+)
 
 diff --git a/configure b/configure
 index a3f0b7a..0ff0380 100755
 --- a/configure
 +++ b/configure
 @@ -3423,6 +3423,8 @@ if test $softmmu = yes ; then
tools=qemu-ga\$(EXESUF) $tools
  fi
fi
 +else
 +  virtfs=no
  fi
  
  # Mac OS X ships with a broken assembler
 




Re: [Qemu-devel] [PATCH trivial] configure: explicitly disable virtfs if softmmu=no

2013-06-11 Thread Peter Maydell
On 11 June 2013 10:22, M. Mohan Kumar mo...@in.ibm.com wrote:
 I tried ./configure --disable-system --enable-virtfs and make. But didnt
 face any build failure. Could you please share your build failure
 information? virtfs-proxy-helper.1 is created inside the fsdev folder.

Michael wrote The build fails in this case in a separate build
tree but your configure line suggests you were building inside
the source tree.

thanks
-- PMM



Re: [Qemu-devel] [PATCH 06/11] snapshot: distinguish id and name in snapshot delete

2013-06-11 Thread Stefan Hajnoczi
On Sat, Jun 08, 2013 at 02:58:02PM +0800, Wenchao Xia wrote:
  static int find_snapshot_by_id_or_name(BlockDriverState *bs, const char 
 *name)

I suggest renaming the argument to make it less confusing: const char 
*name_or_id

  {
 -BDRVQcowState *s = bs-opaque;
 -int i, ret;
 +int ret;
  
 -ret = find_snapshot_by_id(bs, name);
 +ret = find_snapshot_by_id_and_name(bs, name, NULL);
  if (ret = 0)
  return ret;

Since you're touching the other lines in this function you could add {}.

 -for(i = 0; i  s-nb_snapshots; i++) {
 -if (!strcmp(s-snapshots[i].name, name))
 -return i;
 -}
 -return -1;
 +return find_snapshot_by_id_and_name(bs, NULL, name);
  }
  
  /* if no id is provided, a new one is constructed */
 @@ -333,7 +347,7 @@ int qcow2_snapshot_create(BlockDriverState *bs, 
 QEMUSnapshotInfo *sn_info)
  }
  
  /* Check that the ID is unique */
 -if (find_snapshot_by_id(bs, sn_info-id_str) = 0) {
 +if (find_snapshot_by_id_and_name(bs, sn_info-id_str, NULL) = 0) {
  return -EEXIST;
  }
  
 @@ -530,15 +544,21 @@ fail:
  return ret;
  }
  
 -int qcow2_snapshot_delete(BlockDriverState *bs, const char *snapshot_id)
 +int qcow2_snapshot_delete(BlockDriverState *bs,
 +  const char *snapshot_id,
 +  const char *name,
 +  Error **errp)

This patch will fail to compile.  You haven't changed the
.bdrv_snapshot_delete() prototype.

Please make sure every patch compiles.

  {
  BDRVQcowState *s = bs-opaque;
  QCowSnapshot sn;
  int snapshot_index, ret;
  
  /* Search the snapshot */
 -snapshot_index = find_snapshot_by_id_or_name(bs, snapshot_id);
 +snapshot_index = find_snapshot_by_id_and_name(bs, snapshot_id, name);
  if (snapshot_index  0) {
 +error_setg(errp,
 +   Can't find a snapshot with ID %s and name %s,
 +   snapshot_id, name);

Are both snapshot_id and name guaranteed to be non-NULL here?  It is
dangerous to pass NULL strings to sprintf() functions.  IIRC some libc
implementations will crash, others will print (null) like Linux.



Re: [Qemu-devel] [PATCH v5] NVMe: Initial commit for new storage interface

2013-06-11 Thread Kevin Wolf
Am 04.06.2013 um 17:17 hat Keith Busch geschrieben:
 Initial commit for emulated Non-Volatile-Memory Express (NVMe) pci
 storage device.
 
 NVMe is an open, industry driven storage specification defining
 an optimized register and command set designed to deliver the full
 capabilities of non-volatile memory on PCIe SSDs. Further information
 may be found on the organizations website at:
 
 http://www.nvmexpress.org/
 
 This commit implements the minimum from the specification to work with
 existing drivers.
 
 Cc: Keith Busch keith.bu...@gmail.com
 Signed-off-by: Keith Busch keith.bu...@intel.com

Thanks, applied to the block branch.

Kevin



Re: [Qemu-devel] [PATCH trivial] configure: explicitly disable virtfs if softmmu=no

2013-06-11 Thread Michael Tokarev
11.06.2013 13:22, M. Mohan Kumar wrote:
 Michael Tokarev m...@tls.msk.ru writes:
 
 11.06.2013 00:47, Michael Tokarev wrote:
 Or else

  ./configure --disable-system --enable-virtfs

 (which makes no sense by its own but does not error out)
 will fail to build, because it will define CONFIG_VIRTFS,
 and the makefile will try to build virtfs-proxy-helper
 manpage (but not the executable).

 The build fails in this case in a separate build tree, because
^
 the fsdev directory is not created and scripts/texi2pod.pl
 will be called with output = fsdev/virtfs-proxy-helper.pod,
 which can't be created because fsdev/ does not exist.

 
 Hi,
 
 I tried ./configure --disable-system --enable-virtfs and make. But didnt
 face any build failure. Could you please share your build failure
 information? virtfs-proxy-helper.1 is created inside the fsdev folder.

Well, it shouldn't be created to start with ;)

But the key component to this is to build in a separate
subdir:

 mkdir build
 cd build
 ../configure --disable-system --enable-virtfs
 make

this will fail.

It succeeds when run in the source tree because there,
fsdev/ dir does exist.  But in a separate build dir,
when system targets aren't enabled, it isn't created.

Thanks,

/mjt



Re: [Qemu-devel] [RFT PATCH v1 16/30] isa/*: QOM casting sweep

2013-06-11 Thread Andreas Färber
Am 11.06.2013 08:52, schrieb peter.crosthwa...@xilinx.com:
 From: Peter Crosthwaite peter.crosthwa...@xilinx.com
 
 Use standard QOM cast macros. Remove usage of DO_UPCAST and
 direct - style upcasting.
 
 Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
 ---
 
  hw/isa/i82378.c   |  8 
  hw/isa/lpc_ich9.c |  6 +++---
  hw/isa/piix4.c|  4 ++--
  hw/isa/vt82c686.c | 14 +++---
  4 files changed, 16 insertions(+), 16 deletions(-)
[...]
 diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
 index d750413..1eb05b2 100644
 --- a/hw/isa/piix4.c
 +++ b/hw/isa/piix4.c
[...]
 @@ -98,7 +98,7 @@ int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn)
  PCIDevice *d;
  
  d = pci_create_simple_multifunction(bus, devfn, true, PIIX4);
 -*isa_bus = DO_UPCAST(ISABus, qbus, qdev_get_child_bus(d-qdev, 
 isa.0));
 +*isa_bus = DO_UPCAST(ISABus, qbus, qdev_get_child_bus(DEVICE(d), 
 isa.0));

Conflict, my ISABus patch does ISA_BUS() in addition:
http://patchwork.ozlabs.org/patch/249705/

  return d-devfn;
  }
  
 diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
 index 5261927..8ec0d84 100644
 --- a/hw/isa/vt82c686.c
 +++ b/hw/isa/vt82c686.c
[...]
 @@ -450,7 +450,7 @@ ISABus *vt82c686b_init(PCIBus *bus, int devfn)
  
  d = pci_create_simple_multifunction(bus, devfn, true, VT82C686B);
  
 -return DO_UPCAST(ISABus, qbus, qdev_get_child_bus(d-qdev, isa.0));
 +return DO_UPCAST(ISABus, qbus, qdev_get_child_bus(DEVICE(d), isa.0));

Ditto.

  }
  
  static void via_class_init(ObjectClass *klass, void *data)

Otherwise looks fine.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCH] ide-test: fix failure for test_flush

2013-06-11 Thread Andreas Färber
Am 10.06.2013 20:23, schrieb Michael Roth:
 bd07684aacfb61668ae2c25b7dd00b64f3d7c7f3 added a test to ensure BSY
 flag is set when a flush request is in flight. It does this by setting
 a blkdebug breakpoint on flush_to_os before issuing a CMD_FLUSH_CACHE.
 It then resumes CMD_FLUSH_CACHE operation and checks that BSY is unset.
 
 The actual unsetting of BSY does not occur until ide_flush_cb gets
 called in a bh, however, so in some cases this check will race with
 the actual completion.
 
 Fix this by polling the ide status register until BSY flag gets unset
 before we do our final sanity checks. According to
 f68ec8379e88502b4841a110c070e9b118d3151c this is in line with how a guest
 would determine whether or not the device is still busy.
 
 Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com
 ---
  tests/ide-test.c |5 -
  1 file changed, 4 insertions(+), 1 deletion(-)
 
 diff --git a/tests/ide-test.c b/tests/ide-test.c
 index 828e71a..7e2eb94 100644
 --- a/tests/ide-test.c
 +++ b/tests/ide-test.c
 @@ -455,7 +455,10 @@ static void test_flush(void)
  data = inb(IDE_BASE + reg_device);
  g_assert_cmpint(data  DEV, ==, 0);
  
 -data = inb(IDE_BASE + reg_status);
 +do {
 +data = inb(IDE_BASE + reg_status);
 +} while (data  BSY);

Is a busy loop really a good idea for a qtest? CC'ing Anthony.
For the theoretical case that BSY is not cleared it might be better to
terminate the loop with some timeout to get an assertion failure or at
least use some form of sleep() to yield the thread while waiting?

 +
  assert_bit_set(data, DRDY);
  assert_bit_clear(data, BSY | DF | ERR | DRQ);

This BSY clear assertion will always be true now due to the above while
condition; it won't if we change it though.

Regards,
Andreas

  

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



[Qemu-devel] how to do performance monitor for single VM?

2013-06-11 Thread Peter Cheung
Dear AllMy name is Peter, i am working on a open source project called 
Pandora. It is a new admin console for openstack. 
http://peter.kingofcoders.com/?p=663How to do performance monitor for 
single VM? For public cloud billing system, i need to know information about 
CPU/memory/IO traction/Network bandwidth for that VM
Thanksfrom Peter  

Re: [Qemu-devel] [PATCH qom-cpu 47/59] spapr: Abstract spapr_fix_cpu_dt() with qemu_for_each_cpu()

2013-06-11 Thread Andreas Färber
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Am 11.06.2013 04:43, schrieb David Gibson:
 On Sun, Jun 09, 2013 at 09:13:14PM +0200, Andreas F¦rber wrote:
 Signed-off-by: Andreas F¦rber afaer...@suse.de
 
 These days, spapr patches should be CCed to Alexey, instead of me.

Please update MAINTAINERS then, I use scripts/get_maintainer.pl. :)

 Though, fwiw,
 
 Reviewed-by: David Gibson da...@gibson.dropbear.id.au

Thanks, however there's been a sentiment that qemu_for_each_cpu()
should be reverted, so I'll need to respin. Patches 55-56 are not
affected though and hopefully a straightforward cleanup.

Andreas

- -- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nrnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imend￶rffer; HRB 16746 AG Nrnberg
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.19 (GNU/Linux)

iQIcBAEBAgAGBQJRtvf1AAoJEPou0S0+fgE/LDkQAKdi0S6WdOK9Otc5716tqCqq
p1KSjmCWSsA9qFfKZjY3vm6mhadA+GT7h+3Ec2L0DMUqOGsTihaT8xb7qcmRT9NO
KehexTXtD77n81Ssai86rDnOcHsK07yv5xiWXCgeaSkAKKYcVVljOOZBZB3EA3zM
ga4zHbsugf8HWgzHlf17GQDwKTEnxyZQQ1ObNlLmKFHS9qG9KjpvJ5REXVrROAUt
nDb430/x2GICU6KZ1X01LVnBvlTFsvnUl1/g5GdtXqR5ebhtoanJRaY+Yf2dz1Dc
7TIArTyJp4SOJVzg3q1PoFhkv0fOTm1z6N7d7m7O5unQVPX85d46i3efHC9v7taR
EiMrs6waEG0k3Vn5ce3yvBMx6Y9T0wkitbT3hQ4F8QKaLQroyz4NZWZs+YETYeck
KOrCQq1av/rEw4Dos6lgUPgg5WOfClnphd8o7qetfECuqwFEQOXYcfjgM4RZ/vsv
KO4BFAAA7MW7gR0LuZqeczIY0YeMlY9ydeEpXVedB2JvMKSesGMMtv5cH+05nvcS
6NfP7jIGPZmG+YOt2Bid0gnVF54OzJ9s8QoX80t5IL20Wi6VveY5I9JoXTP1ihKJ
vyjLHg1NoCsMSGWwS1U6PO1tV2oozVSiyjZeqYrlwIoeTusicuW3TXeRm+iPQ2Mv
qj4gmxNBeMzt7SpdKXUJ
=VWxz
-END PGP SIGNATURE-



Re: [Qemu-devel] [PATCH qom-cpu 00/15 v8] target-i386: convert CPU features into properties, part 1

2013-06-11 Thread Igor Mammedov
On Wed, 05 Jun 2013 19:04:59 +0200
Andreas Färber afaer...@suse.de wrote:

 Am 05.06.2013 16:39, schrieb Igor Mammedov:
  On Wed, 05 Jun 2013 15:29:08 +0200
  Andreas Färber afaer...@suse.de wrote:
  
  Am 05.06.2013 15:18, schrieb Igor Mammedov:
  It's a rebase of v7 on current qom-cpu tree, since then some patches from 
  it
  were applied to master. Convertion of feature bits is left for part 2
  since it's not ready yet.
 
  v7-v8:
  * split out dynamic properties convertion patch into per property patches
to simplify review
  * drop feature bits convertion
 
  Why is conversion of dynamic properties to static properties still
  needed after I applied a solution to override values of dynamic
  properties with -global for 1.5?
  Do you mean qdev_prop_set_globals_for_type()  co?
 
 Yes.
 
  If yes, then I recall it was acceptable hack to permit more clean
  approach for compat props fixes to work. And we promised Anthony to
  get rid of it when possible.
 
 Indeed, but no one talked about reverting to static properties as the
 solution. :) Instead I was talking about solving this very general
 problem at DeviceState / QOM level.
 
  Now more to the point,
  
  1. if CPU are to be created with device_add(wich is still  a goal)
 cpu_x86_create() won't be created, so it leaves rules out compat
 properties set by qdev_prop_set_globals_for_type().
 
 It does not rule it out, but I think we all agree that we do not want
 calls of it cluttered over subclasses.
 
 Instead we have a very generic problem: instance_init is called
 recursively, parents first, so a parent class cannot do any instance
 initialization *after* its derived classes initialized the instance.
 That's contrary to how realize and other QOM methods work but in
 exchange for the flexibility put the burden of saving and calling the
 parent's implementation onto subclasses.

So far all efforts to do it failed. But I agree that it should be solved
at this level since setting defaults/globals on properties before instance
is completely created (i.e all instance_init()s called) is just wrong.
But it's orthogonal to static vs dynamic properties question.

 That's what I would like to change in some way, possibly a
 instance_post_init hook or the like, similar to how DeviceState got its
 own base class initialization hook to handle static props.
 That would not only keep the work low in this case but may also solve
 the virtio-net initialization problem reported elsewhere.
 
 I'm pretty sure if we moved instance_init into ObjectClass, we'd not
 only get an insurge of *Class structs but also people forgetting to
 savecall the parent type's implementation, resulting in all kinds of
 weird errors, so I don't consider this a real option.
 
 Having properties converted by this series as static would open
 road for:
 - making cpu_x86_parse_featurestr() target specific hook that
   deals with legacy cpu_model parsing and converts provided
   features into global properties.
 
 Such a hook could be implemented today, no dependency on static props, I
 just didn't see the need yet. sparc is the only other target where I
 stumbled over this so far and haven't found time to prepare that yet.
It could be done by board specific code before creating CPUs, I do not
have a preference here (but class hook looks a bit cleaner and less likely
to break).

 
 as result during hot-add device_add can work without
 specifying +-foo1,foo2,level=XXX, it will be applied from
 globals.
 
 Using globals for that is fine with me. That code is currently per-CPU
 whereas -cpu does not allow for differently configured CPUs. Mixed CPU
 configurations would be either instantiated from the board and via -device.
 
 - above will allow to replace create_x86_cpu() with plain
   device_add when subclasses are implemented.
  
  2. I'd like to utilize default values of static properties for defining
 subclasses like here: 
  https://github.com/imammedo/qemu/commit/a48e252a2800bf8dd56320e68e4f9517d0a25e5c
 - that would automatically provide benefit of class introspection
   without creating CPU instance
 - replace current CPU definitions array to a set of class_init_xxx
   for each subclass.
 
 How and when do you actually want to inspect them? What's the use case?
 If we hardcode object_property_set_*() in instance_init then surely it's
 only inspectable in instances, much like the properties added for
 libvirt by Eduardo which didn't seem to disturb anyone. Peter actively
 chose the instance_init option for ARM CPUs, meaning they can only be
 inspected once created.
Yes, currently there is no way to do introspect property defaults at
class level, but it doesn't mean that we shouldn't try to move towards it.
Even if there was an interface to do so, it would still not be much useful
for i386 target since a lot of fixups at realize() stage, that needs to be
fixed as well for 

Re: [Qemu-devel] [PATCH] hw/xen: Use g_free instead of free and fix potential memory leaks

2013-06-11 Thread Stefano Stabellini
On Mon, 10 Jun 2013, Stefan Weil wrote:
 The wrong functions and the missing calls of g_free were reported
 by cppcheck.
 
 Signed-off-by: Stefan Weil s...@weilnetz.de

Acked-by: Stefano Stabellini stefano.stabell...@eu.citrix.com

Are you happy to get this patch upstream via qemu-trivial? Or do you
want me to pick it up?


  hw/xen/xen_pt_config_init.c |4 ++--
  xen-all.c   |8 +---
  2 files changed, 7 insertions(+), 5 deletions(-)
 
 diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
 index 01872db..8ccc2e4 100644
 --- a/hw/xen/xen_pt_config_init.c
 +++ b/hw/xen/xen_pt_config_init.c
 @@ -1777,12 +1777,12 @@ static int 
 xen_pt_config_reg_init(XenPCIPassthroughState *s,
  rc = reg-init(s, reg_entry-reg,
 reg_grp-base_offset + reg-offset, data);
  if (rc  0) {
 -free(reg_entry);
 +g_free(reg_entry);
  return rc;
  }
  if (data == XEN_PT_INVALID_REG) {
  /* free unused BAR register entry */
 -free(reg_entry);
 +g_free(reg_entry);
  return 0;
  }
  /* set register value */
 diff --git a/xen-all.c b/xen-all.c
 index bc105f1..1a1d7bb 100644
 --- a/xen-all.c
 +++ b/xen-all.c
 @@ -389,7 +389,7 @@ static int xen_remove_from_physmap(XenIOState *state,
  if (state-log_for_dirtybit == physmap) {
  state-log_for_dirtybit = NULL;
  }
 -free(physmap);
 +g_free(physmap);
  
  return 0;
  }
 @@ -1030,7 +1030,7 @@ static void xen_read_physmap(XenIOState *state)
  xen_domid, entries[i]);
  value = xs_read(state-xenstore, 0, path, len);
  if (value == NULL) {
 -free(physmap);
 +g_free(physmap);
  continue;
  }
  physmap-start_addr = strtoull(value, NULL, 16);
 @@ -1041,7 +1041,7 @@ static void xen_read_physmap(XenIOState *state)
  xen_domid, entries[i]);
  value = xs_read(state-xenstore, 0, path, len);
  if (value == NULL) {
 -free(physmap);
 +g_free(physmap);
  continue;
  }
  physmap-size = strtoull(value, NULL, 16);
 @@ -1069,12 +1069,14 @@ int xen_hvm_init(void)
  state-xce_handle = xen_xc_evtchn_open(NULL, 0);
  if (state-xce_handle == XC_HANDLER_INITIAL_VALUE) {
  perror(xen: event channel open);
 +g_free(state);
  return -errno;
  }
  
  state-xenstore = xs_daemon_open();
  if (state-xenstore == NULL) {
  perror(xen: xenstore open);
 +g_free(state);
  return -errno;
  }
  
 -- 
 1.7.10.4
 



[Qemu-devel] [PATCH] Makefile: Install qemu-img and qemu-nbd man pages only if built

2013-06-11 Thread Andreas Färber
When splitting openSUSE's qemu and qemu-linux-user packages we noticed
that for linux-user-only builds unrelated man pages got installed.
It's surely possible to delete them before packaging, but not installing
them in the first place seems more logical.

Cc: qemu-sta...@nongnu.org
Signed-off-by: Andreas Färber afaer...@suse.de
---
 Makefile | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 306e7bd..3cfa7d0 100644
--- a/Makefile
+++ b/Makefile
@@ -306,10 +306,13 @@ install-doc: $(DOCS)
$(INSTALL_DATA) QMP/qmp-commands.txt $(DESTDIR)$(qemu_docdir)
 ifdef CONFIG_POSIX
$(INSTALL_DIR) $(DESTDIR)$(mandir)/man1
-   $(INSTALL_DATA) qemu.1 qemu-img.1 $(DESTDIR)$(mandir)/man1
+   $(INSTALL_DATA) qemu.1 $(DESTDIR)$(mandir)/man1
+ifneq ($(TOOLS),)
+   $(INSTALL_DATA) qemu-img.1 $(DESTDIR)$(mandir)/man1
$(INSTALL_DIR) $(DESTDIR)$(mandir)/man8
$(INSTALL_DATA) qemu-nbd.8 $(DESTDIR)$(mandir)/man8
 endif
+endif
 ifdef CONFIG_VIRTFS
$(INSTALL_DIR) $(DESTDIR)$(mandir)/man1
$(INSTALL_DATA) fsdev/virtfs-proxy-helper.1 $(DESTDIR)$(mandir)/man1
-- 
1.8.1.4




Re: [Qemu-devel] [PATCH 1/4] tcg-ppc64: Fix RLDCL opcode

2013-06-11 Thread Anton Blanchard

Hi Richard,

 But that suggests then that we ought not be using XO30.
 Or at least adding a comment.

Good idea, how does this look?

Anton
--

The rldcl instruction doesn't have an sh field, so the minor opcode
is shifted 1 bit. We were using the XO30 macro which shifted the
minor opcode 2 bits.

Remove XO30 and add MD30 and MDS30 macros which match the
Power ISA categories.

Cc: qemu-sta...@nongnu.org
Signed-off-by: Anton Blanchard an...@samba.org
---

Index: b/tcg/ppc64/tcg-target.c
===
--- a/tcg/ppc64/tcg-target.c
+++ b/tcg/ppc64/tcg-target.c
@@ -308,7 +308,8 @@ static int tcg_target_const_match (tcg_t
 
 #define OPCD(opc) ((opc)26)
 #define XO19(opc) (OPCD(19)|((opc)1))
-#define XO30(opc) (OPCD(30)|((opc)2))
+#define MD30(opc) (OPCD(30)|((opc)2))
+#define MDS30(opc) (OPCD(30)|((opc)1))
 #define XO31(opc) (OPCD(31)|((opc)1))
 #define XO58(opc) (OPCD(58)|(opc))
 #define XO62(opc) (OPCD(62)|(opc))
@@ -354,10 +355,10 @@ static int tcg_target_const_match (tcg_t
 #define RLWINM OPCD( 21)
 #define RLWNM  OPCD( 23)
 
-#define RLDICL XO30(  0)
-#define RLDICR XO30(  1)
-#define RLDIMI XO30(  3)
-#define RLDCL  XO30(  8)
+#define RLDICL MD30(  0)
+#define RLDICR MD30(  1)
+#define RLDIMI MD30(  3)
+#define RLDCL  MDS30( 8)
 
 #define BCLR   XO19( 16)
 #define BCCTR  XO19(528)



Re: [Qemu-devel] [Qemu-trivial] [PATCH v1 0/3] Serial cleanup

2013-06-11 Thread Michael Tokarev
10.06.2013 14:23, Peter Crosthwaite wrote:
 Ping!
 
 Any objections to this one going in? perhaps even via trivial queue?

Actually applied all 3 (including 2/3 which weren't submitted to -trivial --
I had some fun verifying it :) to the trivial-patches queue.

Thanks!

/mjt



Re: [Qemu-devel] [Qemu-trivial] [PATCH v2] gtk: implement -full-screen

2013-06-11 Thread Michael Tokarev
10.06.2013 22:04, Peter Wu wrote:
 Aiming for GTK as replacement for SDL, a feature like -full-screen should also
 be implemented.
 
 Bringing the window into full-screen mode is done by activating the 
 Fullscreen
 menu item. This is done after showing the windows to make the cursor and menu
 hidden.
 
 v2: drop -no-frame implementation, use booleans instead of ints and ensure
 consistency between ui state and menu.

Thanks,  applied to the trivial-patches queue.

/mjt



Re: [Qemu-devel] [Qemu-trivial] [PATCH 4/5] memory: use '=' instead of '|=' for memory_region_update_pending

2013-06-11 Thread Michael Tokarev
11.06.2013 09:15, liguang wrote:
 because memory_region_update_pending is bool
 
 Signed-off-by: liguang lig.f...@cn.fujitsu.com
 ---
  memory.c |   18 +-
  1 files changed, 9 insertions(+), 9 deletions(-)
 
 diff --git a/memory.c b/memory.c
 index 5cb8f4a..d99eecd 100644
 --- a/memory.c
 +++ b/memory.c
 @@ -1114,7 +1114,7 @@ void memory_region_set_log(MemoryRegion *mr, bool log, 
 unsigned client)
  
  memory_region_transaction_begin();
  mr-dirty_log_mask = (mr-dirty_log_mask  ~mask) | (log * mask);
 -memory_region_update_pending |= mr-enabled;
 +memory_region_update_pending = mr-enabled;

This is wrong, and the original code was right.  Here and in all other places.

Thanks,

/mjt



Re: [Qemu-devel] [Qemu-trivial] [PATCH 3/5] qemu-char: pass bool parameter for qemu_opt_get_bool

2013-06-11 Thread Michael Tokarev
11.06.2013 09:15, liguang wrote:
 Signed-off-by: liguang lig.f...@cn.fujitsu.com
 ---
  qemu-char.c |8 
  1 files changed, 4 insertions(+), 4 deletions(-)
 
 diff --git a/qemu-char.c b/qemu-char.c
 index d04b429..8092eb8 100644
 --- a/qemu-char.c
 +++ b/qemu-char.c
 @@ -2767,10 +2767,10 @@ static CharDriverState *qemu_chr_open_socket(QemuOpts 
 *opts)
  int is_unix;
  int is_telnet;
  
 -is_listen  = qemu_opt_get_bool(opts, server, 0);
 -is_waitconnect = qemu_opt_get_bool(opts, wait, 1);
 -is_telnet  = qemu_opt_get_bool(opts, telnet, 0);
 -do_nodelay = !qemu_opt_get_bool(opts, delay, 1);
 +is_listen  = qemu_opt_get_bool(opts, server, false);
 +is_waitconnect = qemu_opt_get_bool(opts, wait, true);
 +is_telnet  = qemu_opt_get_bool(opts, telnet, false);
 +do_nodelay = !qemu_opt_get_bool(opts, delay, true);
  is_unix= qemu_opt_get(opts, path) != NULL;
  if (!is_listen)
  is_waitconnect = 0;

While we're at it, all the is_* variables themselves should be made
bool instead of int too.

Thanks,

/mjt




Re: [Qemu-devel] [PATCH 2/5] vnc: pass bool parameter for vnc_listen_read

2013-06-11 Thread Andreas Färber
Am 11.06.2013 07:15, schrieb liguang:
 Signed-off-by: liguang lig.f...@cn.fujitsu.com

Reviewed-by: Andreas Färber afaer...@suse.de

CC'ing Tim.

Andreas

 ---
  ui/vnc.c |4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/ui/vnc.c b/ui/vnc.c
 index 7d22660..1a8b940 100644
 --- a/ui/vnc.c
 +++ b/ui/vnc.c
 @@ -2889,13 +2889,13 @@ static void vnc_listen_read(void *opaque, bool 
 websocket)
  
  static void vnc_listen_regular_read(void *opaque)
  {
 -vnc_listen_read(opaque, 0);
 +vnc_listen_read(opaque, false);
  }
  
  #ifdef CONFIG_VNC_WS
  static void vnc_listen_websocket_read(void *opaque)
  {
 -vnc_listen_read(opaque, 1);
 +vnc_listen_read(opaque, true);
  }
  #endif /* CONFIG_VNC_WS */
  
 


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCH 1/5] vnc: pass bool pararmeter for vnc_connect

2013-06-11 Thread Andreas Färber
parameter

Am 11.06.2013 07:15, schrieb liguang:
 type last parameter of vnc_connect if bool,

Type of last ..., is

 so pass 'false' instead of '0' for it.
 
 Signed-off-by: liguang lig.f...@cn.fujitsu.com

Michael, can you fix those up? Then,

Reviewed-by: Andreas Färber afaer...@suse.de

Thanks,
Andreas

 ---
  ui/vnc.c |4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/ui/vnc.c b/ui/vnc.c
 index dfc7459..7d22660 100644
 --- a/ui/vnc.c
 +++ b/ui/vnc.c
 @@ -3283,7 +3283,7 @@ void vnc_display_open(DisplayState *ds, const char 
 *display, Error **errp)
  if (csock  0) {
  goto fail;
  }
 -vnc_connect(vs, csock, 0, 0);
 +vnc_connect(vs, csock, 0, false);
  } else {
  /* listen for connects */
  char *dpy;
 @@ -3345,5 +3345,5 @@ void vnc_display_add_client(DisplayState *ds, int 
 csock, int skipauth)
  {
  VncDisplay *vs = vnc_display;
  
 -vnc_connect(vs, csock, skipauth, 0);
 +vnc_connect(vs, csock, skipauth, false);
  }
 


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



[Qemu-devel] virtio-scsi and error handling

2013-06-11 Thread Hannes Reinecke
Hi Stefan,

I currently playing around with improving SCSI EH, optimizing
command aborts and the like.

And, supposing it to be a nice testbed, tried to make things work
with virtio_scsi.

However, looking at the code there I've found virtscsi_tmf() just
uses 'wait_for_completion', with no timeout specified. So in effect
any abort might stall forever.

Wouldn't it be more sensible to use 'wait_for_completion_timeout'
here, to allow the error escalation to continue?
This would especially be useful when running with multipathing,
as the underlying device might stall, and aio_cancel() doesn't work
reliably, if at all.

Also I've found that there is no host reset. Currently the virtio
semantics seem to require reliable communication, ie for every
command send there _has_ to be a response.

Long and painful experience with RAID HBAs has shown that this model
works okay for the lower-level escalations, but you absolutely need
a host reset to restore communication.
In the case of virtio I would think that a virtio-level reset for
host_reset would be a sensible idea.

Any opinions from your side?

Cheers,

Hannes
-- 
Dr. Hannes Reinecke   zSeries  Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)



Re: [Qemu-devel] [PATCH v2]booke: timer: Deactivate timer for target_bit above 61

2013-06-11 Thread Bhushan Bharat-R65777


 -Original Message-
 From: Alexander Graf [mailto:ag...@suse.de]
 Sent: Monday, June 10, 2013 11:40 PM
 To: Wood Scott-B07421
 Cc: Bhushan Bharat-R65777; Andreas Färber; qemu-...@nongnu.org; qemu-
 de...@nongnu.org; Wood Scott-B07421
 Subject: Re: [Qemu-devel] [PATCH v2]booke: timer: Deactivate timer for
 target_bit above 61
 
 
 On 10.06.2013, at 19:20, Scott Wood wrote:
 
  On 06/10/2013 09:26:18 AM, Alexander Graf wrote:
  On 06/10/2013 02:47 PM, Bhushan Bharat-R65777 wrote:
  -Original Message-
  From: Andreas Färber [mailto:afaer...@suse.de]
  Sent: Monday, June 10, 2013 5:43 PM
  To: Bhushan Bharat-R65777
  Cc: qemu-...@nongnu.org; qemu-devel@nongnu.org; ag...@suse.de; Wood
  Scott- B07421; Bhushan Bharat-R65777
  Subject: Re: [Qemu-devel] [PATCH v2]booke: timer: Deactivate timer
  for target_bit above 61 So IIUC we can only allow 63 bits due to
  signedness, thus a maximum of (1  62), thus target_bit= 61.
  Any chance at least the comment can be worded to explain that any
  better? Maybe also use (target-bit + 1= 63) or period  INT64_MAX as
 condition?
  How about this:
  /* QEMU timer supports a maximum timer of INT64_MAX
 (0x7fff_).
   * Run booke fit/wdog timer when
   * ((1ULL  target_bit + 1)  0x4000_), i.e target_bit =
 61.
   * Also the time with this maximum target_bit (with current range of
   * CPU frequency PowerPC supports) will be many many years. So it is
   * pretty safe to stop the timer above this threshold. */
  How about
   /* This timeout will take years to trigger. Treat the timer as
  disabled. */
 
  There should be at least a brief mention that it's because the QEMU
  timer can't handle larger values,
 
 If it can't handle higher values, maybe it's better to just set the timer 
 value
 to INT64_MAX when we detect an overflow? That would make the code plainly
 obvious.
 

What about below comment (a mix of both :)):

/* Timeout calculated with (target_bit + 1)  62 will take
 * hundreds of years to trigger. Treat the timer as disabled.
 * Also this timeout is within the qemu supported maximum
 * timeout limit (INT64_MAX.). */

-Bharat

 
 Alex
 
  with the detailed explanation in the changelog.  A better lower bound on the
 number of years would be nice as well (e.g. hundreds of years).
 
  -Scott
 





Re: [Qemu-devel] [Qemu-trivial] [PATCH 1/5] vnc: pass bool pararmeter for vnc_connect

2013-06-11 Thread Michael Tokarev
11.06.2013 09:15, liguang wrote:
 type last parameter of vnc_connect if bool,
 so pass 'false' instead of '0' for it.

There's another parameter in here, `skipauth', which should be
bool in vnc_connect(), and should be bool in vnc_display_add_client()
too.

Also, there's no big point in splitting 1/5 and 2/5 (vnc_listen_read),
I think.

Does something like the below look ok? (not even compile-tested)
(and I'd really rename `skipauth' to `doauth' everywhere, to mean
exactly the opposite so that we don't have double negatives, but
it is too late already)

From: Michael Tokarev m...@tls.msk.ru
Date:   Tue Jun 11 15:42:44 2013 +0400

vnc: use booleans for vnc_connect, vnc_listen_read and 
vnc_display_add_client

Some arguments to these functions are booleans - either by declaration,
or by actual usage, but sometimes value of 0 or 1 is passed for a bool,
and sometimes it is declared as int but a bool value, or true/false,
is passed to it instead.  Clean it up a bit.

Cc: liguang lig.f...@cn.fujitsu.com
Signed-off-by: Michael Tokarev m...@tls.msk.ru

diff --git a/include/ui/console.h b/include/ui/console.h
index f1d79f9..98edf41 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -314,7 +314,7 @@ void cocoa_display_init(DisplayState *ds, int full_screen);
 /* vnc.c */
 void vnc_display_init(DisplayState *ds);
 void vnc_display_open(DisplayState *ds, const char *display, Error **errp);
-void vnc_display_add_client(DisplayState *ds, int csock, int skipauth);
+void vnc_display_add_client(DisplayState *ds, int csock, bool skipauth);
 char *vnc_display_local_addr(DisplayState *ds);
 #ifdef CONFIG_VNC
 int vnc_display_password(DisplayState *ds, const char *password);
diff --git a/ui/vnc.c b/ui/vnc.c
index dfc7459..5601cc3 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -2771,7 +2771,8 @@ static void vnc_refresh(DisplayChangeListener *dcl)
 }
 }

-static void vnc_connect(VncDisplay *vd, int csock, int skipauth, bool 
websocket)
+static void vnc_connect(VncDisplay *vd, int csock,
+bool skipauth, bool websocket)
 {
 VncState *vs = g_malloc0(sizeof(VncState));
 int i;
@@ -2883,19 +2884,19 @@ static void vnc_listen_read(void *opaque, bool 
websocket)
 }

 if (csock != -1) {
-vnc_connect(vs, csock, 0, websocket);
+vnc_connect(vs, csock, false, websocket);
 }
 }

 static void vnc_listen_regular_read(void *opaque)
 {
-vnc_listen_read(opaque, 0);
+vnc_listen_read(opaque, false);
 }

 #ifdef CONFIG_VNC_WS
 static void vnc_listen_websocket_read(void *opaque)
 {
-vnc_listen_read(opaque, 1);
+vnc_listen_read(opaque, true);
 }
 #endif /* CONFIG_VNC_WS */

@@ -3283,7 +3284,7 @@ void vnc_display_open(DisplayState *ds, const char 
*display, Error **errp)
 if (csock  0) {
 goto fail;
 }
-vnc_connect(vs, csock, 0, 0);
+vnc_connect(vs, csock, false, false);
 } else {
 /* listen for connects */
 char *dpy;
@@ -3341,9 +3342,9 @@ fail:
 #endif /* CONFIG_VNC_WS */
 }

-void vnc_display_add_client(DisplayState *ds, int csock, int skipauth)
+void vnc_display_add_client(DisplayState *ds, int csock, bool skipauth)
 {
 VncDisplay *vs = vnc_display;

-vnc_connect(vs, csock, skipauth, 0);
+vnc_connect(vs, csock, skipauth, false);
 }




Re: [Qemu-devel] qemu-1.5.0 savevm error -95 while writing vm with ceph-rbd as storage-backend

2013-06-11 Thread Oliver Francke

Hi Alexandre, Josh,

sorry for coming back so very late, I tried the patch and though I could 
not get it to work properly - very likely my fault - how would it be to 
integrate it into the rbd-handler of qemu?


Josh? I think you are CC'd from another qemu-ticket anyway?

I could just ignore the EOPNOTSUPP or whatever it's called, but a smooth 
integration of live-snapshots would be so cool ;)


Kind regards,

Oliver.

On 05/24/2013 05:37 PM, Alexandre DERUMIER wrote:

Hi,

For Proxmox, we have made some patchs to split the savevm process,

to be able to save the memory to an external volume. (and not the current 
volume).

For rbd, we create a new rbd volume to store the memory.

qemu patch is here :
https://git.proxmox.com/?p=pve-qemu-kvm.git;a=blob;f=debian/patches/internal-snapshot-async.patch;h=c67a97ea497fe31ff449acb79e04dc1c53b25578;hb=HEAD

- Mail original -

De: Wido den Hollander w...@42on.com
À: Oliver Francke oliver.fran...@filoo.de
Cc: ceph-de...@vger.kernel.org
Envoyé: Vendredi 24 Mai 2013 17:08:35
Objet: Re: qemu-1.5.0 savevm error -95 while writing vm with ceph-rbd as 
storage-backend

On 05/24/2013 09:46 AM, Oliver Francke wrote:

Hi,

with a running VM I encounter this strange behaviour, former
qemu-versions don't show up such an error.
Perhaps this comes from the rbd-backend in qemu-1.5.0 in combination
with ceph-0.56.6? Therefore my
crosspost.

Even if I have no real live-snapshot avail - they know of this
restriction -, it's more work for the customers
to perform a shutdown before the wonna do some changes to their VM ;)


Doesn't Qemu try to save the memory state to RBD here as well? That
doesn't work and fails.


Any hints welcome,

Oliver.






--

Oliver Francke

filoo GmbH
Moltkestraße 25a
0 Gütersloh
HRB4355 AG Gütersloh

Geschäftsführer: S.Grewing | J.Rehpöhler | C.Kunz

Folgen Sie uns auf Twitter: http://twitter.com/filoogmbh




Re: [Qemu-devel] [PATCH qom-cpu 27/59] cpu: Turn cpu_unassigned_access() into a CPUState hook

2013-06-11 Thread Stefano Stabellini
On Tue, 11 Jun 2013, Andreas Färber wrote:
 Am 09.06.2013 21:12, schrieb Andreas Färber:
  diff --git a/include/qom/cpu.h b/include/qom/cpu.h
  index a69c09c..814d067 100644
  --- a/include/qom/cpu.h
  +++ b/include/qom/cpu.h
 [...]
  @@ -383,6 +401,21 @@ void cpu_interrupt(CPUState *cpu, int mask);
   
   #endif /* USER_ONLY */
   
  +#ifndef CONFIG_USER_ONLY
  +
  +static inline void cpu_unassigned_access(CPUState *cpu, hwaddr addr,
  + bool is_write, bool is_exec,
  + int opaque, unsigned size)
  +{
  +CPUClass *cc = CPU_GET_CLASS(cpu);
  +
  +if (cc-do_unassigned_access) {
  +cc-do_unassigned_access(cpu, addr, is_write, is_exec, opaque, 
  size);
  +}
  +}
  +
  +#endif
  +
   /**
* cpu_reset_interrupt:
* @cpu: The CPU to clear the interrupt on.
  diff --git a/memory.c b/memory.c
  index 5cb8f4a..74daf03 100644
  --- a/memory.c
  +++ b/memory.c
  @@ -857,9 +857,8 @@ static uint64_t unassigned_mem_read(void *opaque, 
  hwaddr addr,
   #ifdef DEBUG_UNASSIGNED
   printf(Unassigned mem read  TARGET_FMT_plx \n, addr);
   #endif
  -#if defined(TARGET_ALPHA) || defined(TARGET_SPARC) || 
  defined(TARGET_MICROBLAZE)
  -cpu_unassigned_access(cpu_single_env, addr, 0, 0, 0, size);
  -#endif
  +cpu_unassigned_access(ENV_GET_CPU(cpu_single_env), addr, false, false, 
  0,
  +  size);
   return 0;
   }
   
  @@ -869,9 +868,8 @@ static void unassigned_mem_write(void *opaque, hwaddr 
  addr,
   #ifdef DEBUG_UNASSIGNED
   printf(Unassigned mem write  TARGET_FMT_plx  = 0x%PRIx64\n, 
  addr, val);
   #endif
  -#if defined(TARGET_ALPHA) || defined(TARGET_SPARC) || 
  defined(TARGET_MICROBLAZE)
  -cpu_unassigned_access(cpu_single_env, addr, 1, 0, 0, size);
  -#endif
  +cpu_unassigned_access(ENV_GET_CPU(cpu_single_env), addr, true, false, 
  0,
  +  size);
   }
   
   static bool unassigned_mem_accepts(void *opaque, hwaddr addr,
 
 Taking a wild guess here, could it be that cpu_single_env is NULL in the
 Xen case, and we're tripping over cpu_unassigned_access() trying
 CPU_GET_CLASS(ENV_GET_CPU(NULL)) and asserting?

Good guess! cpu_single_env is NULL and removing the two calls to
cpu_unassigned_access fixes the problem.

Re: [Qemu-devel] [Qemu-trivial] [PATCH] Makefile: Install qemu-img and qemu-nbd man pages only if built

2013-06-11 Thread Michael Tokarev
11.06.2013 15:13, Andreas Färber wrote:
 When splitting openSUSE's qemu and qemu-linux-user packages we noticed
 that for linux-user-only builds unrelated man pages got installed.
 It's surely possible to delete them before packaging, but not installing
 them in the first place seems more logical.

Thanks, applied to the trivial patches queue.

It is somethigh I wanted to do for a long time -- exactly due to the
same reason, when we build qemu-user[-static] target on debian it
installs the irrelevant manpages... ;)

/mjt




Re: [Qemu-devel] [Qemu-trivial] [PATCH] target-sparc: Replace free by g_free

2013-06-11 Thread Michael Tokarev
Thanks, applied all 4(*) to trivial-patches queue.

(*)
 target-sparc: Replace free by g_free
 hw/scsi: Don't increment a boolean value
 device tree: Fix cppcheck warning
 hw/xen: Use g_free instead of free and fix potential memory leaks

(I think it wont hurt if the xen one will come from both -trivial
and xen trees, first one wins ;)

/mjt



Re: [Qemu-devel] [PATCH] ide-test: fix failure for test_flush

2013-06-11 Thread Kevin Wolf
Am 11.06.2013 um 12:05 hat Andreas Färber geschrieben:
 Am 10.06.2013 20:23, schrieb Michael Roth:
  bd07684aacfb61668ae2c25b7dd00b64f3d7c7f3 added a test to ensure BSY
  flag is set when a flush request is in flight. It does this by setting
  a blkdebug breakpoint on flush_to_os before issuing a CMD_FLUSH_CACHE.
  It then resumes CMD_FLUSH_CACHE operation and checks that BSY is unset.
  
  The actual unsetting of BSY does not occur until ide_flush_cb gets
  called in a bh, however, so in some cases this check will race with
  the actual completion.
  
  Fix this by polling the ide status register until BSY flag gets unset
  before we do our final sanity checks. According to
  f68ec8379e88502b4841a110c070e9b118d3151c this is in line with how a guest
  would determine whether or not the device is still busy.
  
  Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com
  ---
   tests/ide-test.c |5 -
   1 file changed, 4 insertions(+), 1 deletion(-)
  
  diff --git a/tests/ide-test.c b/tests/ide-test.c
  index 828e71a..7e2eb94 100644
  --- a/tests/ide-test.c
  +++ b/tests/ide-test.c
  @@ -455,7 +455,10 @@ static void test_flush(void)
   data = inb(IDE_BASE + reg_device);
   g_assert_cmpint(data  DEV, ==, 0);
   
  -data = inb(IDE_BASE + reg_status);
  +do {
  +data = inb(IDE_BASE + reg_status);
  +} while (data  BSY);
 
 Is a busy loop really a good idea for a qtest? CC'ing Anthony.
 For the theoretical case that BSY is not cleared it might be better to
 terminate the loop with some timeout to get an assertion failure or at
 least use some form of sleep() to yield the thread while waiting?

FWIW, the floppy test already has a busy wait for IRQs, which results in
the same failure mode. I think it's okay for a test case, but if someone
felt like implementing timeouts, that would be great and we could apply
them on top.

Kevin



[Qemu-devel] QEMU 1.6 release schedule

2013-06-11 Thread Anthony Liguori
FYI, posted on http://wiki.qemu.org/Planning/1.6

The only small change compared to 1.5 is three release candidates
instead of two in the original plan.  I think having the third release
candidate was helpful for 1.5.

| 2013-05-20
| Beginning of 1.6 development phase
|-
| 2013-06-15
| Mid-point of development cycle
|-
| 2013-07-15
| [[Planning/SoftFeatureFreeze|Soft feature freeze]].  Major features should 
have initial code committed by this date.
|-
| 2013-07-29
| [[Planning/HardFeatureFreeze|Hard feature freeze]].  Tag v1.6.0-rc0, only bug 
fixes committed after this point
|-
| 2013-08-01
| Tag v1.6.0-rc1
|-
| 2013-08-07
| Tag v1.6.0-rc2
|-
| 2013-08-12
| Tag v1.6.0-rc3
|-
| 2013-08-15
| Tag v1.6.0

Regards,

Anthony Liguori




Re: [Qemu-devel] [Qemu-trivial] [PATCH] Unbreak -no-quit for GTK, validate SDL options

2013-06-11 Thread Michael Tokarev
11.06.2013 12:55, Peter Wu wrote:
 Certain options (-no-frame, -alt-grab, -ctrl-grab) only make sense with SDL.
 When compiling without SDL, these options (and -no-quit) print an error 
 message
 and exit qemu.
 
 In case QEMU is compiled with SDL support, the three aforementioned options
 still do not make sense with other display types. This patch addresses that
 issue by printing a warning. I have chosen not to exit QEMU afterwards because
 having the option is not harmful and before this patch it would be ignored
 anyway.
 
 By delaying the sanity check from compile-time with some ifdefs to run-time,
 -no-quit is now also properly supported when compiling without SDL.

Thanks, this is also something I wanted to do for a long time, -- to know
when some options makes no sense (or not implemented) instead of wondering
what I did wrong and why it does not work as expected... ;)

Applied to the trivial patches queue.

/mjt



Re: [Qemu-devel] [PATCH] target-sparc: Replace free by g_free

2013-06-11 Thread Andreas Färber
Am 10.06.2013 22:40, schrieb Stefan Weil:
 The wrong function was reported by cppcheck.
 
 Signed-off-by: Stefan Weil s...@weilnetz.de

Reviewed-by: Andreas Färber afaer...@suse.de

 ---
  target-sparc/cpu.c |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/target-sparc/cpu.c b/target-sparc/cpu.c
 index 290b580..13bb7bb 100644
 --- a/target-sparc/cpu.c
 +++ b/target-sparc/cpu.c
 @@ -614,7 +614,7 @@ static int cpu_sparc_find_by_name(sparc_def_t *cpu_def, 
 const char *cpu_model)
  return 0;
  
   error:
 -free(s);
 +g_free(s);
  return -1;
  }
  

So s is for the string, and matches occurrence above, fine.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCH v2 0/9] QMP/HMP: add error reason to open failures

2013-06-11 Thread Luiz Capitulino
On Tue, 11 Jun 2013 09:44:08 +0200
Stefan Hajnoczi stefa...@gmail.com wrote:

 On Mon, Jun 10, 2013 at 01:02:19PM -0400, Luiz Capitulino wrote:
 I should have qualified by Reviewed-by: with reviewed block layer changes.

I've added it only to the block layer patches.



Re: [Qemu-devel] [PATCH trivial] configure: explicitly disable virtfs if softmmu=no

2013-06-11 Thread Michael Tokarev
11.06.2013 01:45, Peter Maydell wrote:
 On 10 June 2013 21:47, Michael Tokarev m...@tls.msk.ru wrote:
 Or else

  ./configure --disable-system --enable-virtfs

 (which makes no sense by its own but does not error out)
 will fail to build, because it will define CONFIG_VIRTFS,
 and the makefile will try to build virtfs-proxy-helper
 manpage (but not the executable).

 Cc: qemu-triv...@nongnu.org
 Cc: M. Mohan Kumar mo...@in.ibm.com
 Signed-off-by: Michael Tokarev m...@tls.msk.ru
 ---
  configure |2 ++
  1 file changed, 2 insertions(+)

 diff --git a/configure b/configure
 index a3f0b7a..0ff0380 100755
 --- a/configure
 +++ b/configure
 @@ -3423,6 +3423,8 @@ if test $softmmu = yes ; then
tools=qemu-ga\$(EXESUF) $tools
  fi
fi
 +else
 +  virtfs=no
  fi
 
 This doesn't feel to me like it's quite the right way
 to fix this bug. The current code in configure seems
 to tangle up (a) was virtfs requested and can we do it?
 with (b) what do we need to do if it was? (build some
 extra tools) and (c) when does it make sense? not for
 linux-user targets. So you end up with an 'else virtfs=no'
 clause added in an odd place. If the mess was untangled
 then this probably wouldn't be necessary.

Um. I don't think that tangling is a bad thing really.
Having different variables or options for it will be
too bloated, in my opinion.  I don't think there should
be anything done with it.

How about something like this:

--- a/configure
+++ b/configure
@@ -3810,7 +3810,7 @@ fi
 if test $libattr = yes ; then
   echo CONFIG_LIBATTR=y  $config_host_mak
 fi
-if test $virtfs = yes ; then
+if test $virtfs = yes  test $target_softmmu = yes ; then
   echo CONFIG_VIRTFS=y  $config_host_mak
 fi
 if test $vhost_scsi = yes ; then

(BTW, why configure uses this test instead of more readable [ ] ? )

 Also, disabling building tools and docs in general seems
 broken: --disable-tools disables building qemu-img, for
 instance, but not its documentation. So maybe we should
 fix this by generally making sure we don't build the docs
 unless we build the tool as well.

This has been addressed by a separate patch sent by afaerber.

Thanks,

/mjt



  1   2   >