Port of watchdogs to vmstate
cover Port of watchdogs to vmstate
In this series:
- port i6300esb to vmstate
- minor cleanups of i6300esb
- create IB700State for ib700
- port ib700 to vmstate
Juan Quintela (6):
wdt_i6300esb: port to vmstate
wdt_i6300esb: remove useless casts from void *
wdt_i6300esb: move PCI_DEVICE_IDE_INTEL_ESB_9 to pci_ids.h
ib700: Introduce IB700State
ib700: move timer to IB700State
ib700: port to vmstate
hw/pci_ids.h | 1 + hw/wdt_i6300esb.c | 81 ++++++++++++++++++---------------------------------- hw/wdt_ib700.c | 53 +++++++++++++++++++--------------- 3 files changed, 59 insertions(+), 76 deletions(-)
PATCH 1/6 wdt_i6300esb: port to vmstate
--- hw/wdt_i6300esb.c | 67 ++++++++++++++++++---------------------------------- 1 files changed, 23 insertions(+), 44 deletions(-)
hw/wdt_i6300esb.c +23 -44
@@ -369,48 +369,28 @@ static void i6300esb_map(PCIDevice *dev, int region_num,/* qemu_register_coalesced_mmio (addr, 0x10); ? */ } -static void i6300esb_save (QEMUFile *f,void *vp) -{ -I6300State *d = (I6300State *) vp; - -pci_device_save (&d->dev, f); -qemu_put_be32 (f, d->reboot_enabled); -qemu_put_be32 (f, d->clock_scale); -qemu_put_be32 (f, d->int_type); -qemu_put_be32 (f, d->free_run); -qemu_put_be32 (f, d->locked); -qemu_put_be32 (f, d->enabled); -qemu_put_timer (f, d->timer); -qemu_put_be32 (f, d->timer1_preload); -qemu_put_be32 (f, d->timer2_preload); -qemu_put_be32 (f, d->stage); -qemu_put_be32 (f, d->unlock_state); -qemu_put_be32 (f, d->previous_reboot_flag); -} - -static int i6300esb_load (QEMUFile *f,void *vp,int version) -{ -I6300State *d = (I6300State *) vp; - -if (version !=sizeof (I6300State)) -return -EINVAL ; - -pci_device_load (&d->dev, f); - d->reboot_enabled =qemu_get_be32 (f); - d->clock_scale =qemu_get_be32 (f); - d->int_type =qemu_get_be32 (f); - d->free_run =qemu_get_be32 (f); - d->locked =qemu_get_be32 (f); - d->enabled =qemu_get_be32 (f); -qemu_get_timer (f, d->timer); - d->timer1_preload =qemu_get_be32 (f); - d->timer2_preload =qemu_get_be32 (f); - d->stage =qemu_get_be32 (f); - d->unlock_state =qemu_get_be32 (f); - d->previous_reboot_flag =qemu_get_be32 (f); - -return 0 ; -} +static const VMStateDescription vmstate_i6300esb = { + .name ="i6300esb_wdt" , + .version_id =sizeof (I6300State), + .minimum_version_id =sizeof (I6300State), + .minimum_version_id_old =sizeof (I6300State), + .fields = (VMStateField []) { +VMSTATE_PCI_DEVICE (dev, I6300State), +VMSTATE_INT32 (reboot_enabled, I6300State), +VMSTATE_INT32 (clock_scale, I6300State), +VMSTATE_INT32 (int_type, I6300State), +VMSTATE_INT32 (free_run, I6300State), +VMSTATE_INT32 (locked, I6300State), +VMSTATE_INT32 (enabled, I6300State), +VMSTATE_TIMER (timer, I6300State), +VMSTATE_UINT32 (timer1_preload, I6300State), +VMSTATE_UINT32 (timer2_preload, I6300State), +VMSTATE_INT32 (stage, I6300State), +VMSTATE_INT32 (unlock_state, I6300State), +VMSTATE_INT32 (previous_reboot_flag, I6300State), +VMSTATE_END_OF_LIST () + } +};static int i6300esb_init (PCIDevice *dev) {
@@ -439,8 +419,7 @@ static int i6300esb_init(PCIDevice *dev)pci_register_bar (&d->dev,0 ,0x10 ,PCI_ADDRESS_SPACE_MEM , i6300esb_map); -register_savevm ("i6300esb_wdt" ,-1 ,sizeof (I6300State), - i6300esb_save, i6300esb_load, d); +vmstate_register (-1 , &vmstate_i6300esb, d);return 0 ; }
Signature · 1 line
1.6.2.5
PATCH 2/6 wdt_i6300esb: remove useless casts from void *
In reply to Juan Quintela--- hw/wdt_i6300esb.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
hw/wdt_i6300esb.c +5 -5
@@ -163,7 +163,7 @@ static void i6300esb_reset(I6300State *d)*/ static void i6300esb_timer_expired (void *vp) { -I6300State *d = (I6300State *) vp; +I6300State *d = vp;i6300esb_debug ("stage %d\n" , d->stage);
@@ -257,7 +257,7 @@ static uint32_t i6300esb_mem_readb(void *vp, target_phys_addr_t addr)static uint32_t i6300esb_mem_readw (void *vp,target_phys_addr_t addr) {uint32_t data =0 ; -I6300State *d = (I6300State *) vp; +I6300State *d = vp;i6300esb_debug ("addr = %x\n" , (int ) addr);
@@ -281,7 +281,7 @@ static uint32_t i6300esb_mem_readl(void *vp, target_phys_addr_t addr)static void i6300esb_mem_writeb (void *vp,target_phys_addr_t addr,uint32_t val) { -I6300State *d = (I6300State *) vp; +I6300State *d = vp;i6300esb_debug ("addr = %x, val = %x\n" , (int ) addr, val);
@@ -293,7 +293,7 @@ static void i6300esb_mem_writeb(void *vp, target_phys_addr_t addr, uint32_t val)static void i6300esb_mem_writew (void *vp,target_phys_addr_t addr,uint32_t val) { -I6300State *d = (I6300State *) vp; +I6300State *d = vp;i6300esb_debug ("addr = %x, val = %x\n" , (int ) addr, val);
@@ -326,7 +326,7 @@ static void i6300esb_mem_writew(void *vp, target_phys_addr_t addr, uint32_t val)static void i6300esb_mem_writel (void *vp,target_phys_addr_t addr,uint32_t val) { -I6300State *d = (I6300State *) vp; +I6300State *d = vp;i6300esb_debug ("addr = %x, val = %x\n" , (int ) addr, val);
Signature · 1 line
1.6.2.5
PATCH 3/6 wdt_i6300esb: move PCI_DEVICE_IDE_INTEL_ESB_9 to pci_ids.h
In reply to Juan Quintela--- hw/pci_ids.h | 1 + hw/wdt_i6300esb.c | 4 ---- 2 files changed, 1 insertions(+), 4 deletions(-)
hw/pci_ids.h +1 -0
@@ -88,6 +88,7 @@#define PCI_VENDOR_ID_INTEL 0x8086#define PCI_DEVICE_ID_INTEL_82441 0x1237#define PCI_DEVICE_ID_INTEL_82801AA_5 0x2415 +#define PCI_DEVICE_ID_INTEL_ESB_9 0x25ab#define PCI_DEVICE_ID_INTEL_82371SB_0 0x7000#define PCI_DEVICE_ID_INTEL_82371SB_1 0x7010#define PCI_DEVICE_ID_INTEL_82371SB_2 0x7020
hw/wdt_i6300esb.c +0 -4
@@ -36,10 +36,6 @@#define i6300esb_debug (fs,...)#endif -#ifndef PCI_DEVICE_ID_INTEL_ESB_9 -#define PCI_DEVICE_ID_INTEL_ESB_9 0x25ab -#endif -/* PCI configuration registers */ #define ESB_CONFIG_REG 0x60/* Config register */ #define ESB_LOCK_REG 0x68/* WDT lock register */
Signature · 1 line
1.6.2.5
PATCH 4/6 ib700: Introduce IB700State
In reply to Juan Quintela--- hw/wdt_ib700.c | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-)
hw/wdt_ib700.c +11 -5
@@ -35,6 +35,10 @@#define ib700_debug (fs,...)#endif +typedef struct IB700state { +ISADevice dev; +}IB700State ; +/* This is the timer. We use a global here because the watchdog * code ensures there is only one watchdog (it is located at a fixed, * unchangable IO port, so there could only ever be one anyway).
@@ -90,10 +94,12 @@ static int ib700_load(QEMUFile *f, void *vp, int version)static int wdt_ib700_init (ISADevice *dev) { - timer =qemu_new_timer (vm_clock, ib700_timer_expired,NULL ); -register_savevm ("ib700_wdt" ,-1 ,0 , ib700_save, ib700_load,NULL ); -register_ioport_write (0x441 ,2 ,1 , ib700_write_disable_reg,NULL ); -register_ioport_write (0x443 ,2 ,1 , ib700_write_enable_reg,NULL ); +IB700State *s =DO_UPCAST (IB700State, dev, dev); + + timer =qemu_new_timer (vm_clock, ib700_timer_expired, s); +register_savevm ("ib700_wdt" ,-1 ,0 , ib700_save, ib700_load, s); +register_ioport_write (0x441 ,2 ,1 , ib700_write_disable_reg, s); +register_ioport_write (0x443 ,2 ,1 , ib700_write_enable_reg, s);return 0 ; }
@@ -105,7 +111,7 @@ static WatchdogTimerModel model = {static ISADeviceInfo wdt_ib700_info = { .qdev.name ="ib700" , - .qdev.size =sizeof (ISADevice), + .qdev.size =sizeof (IB700State), .init = wdt_ib700_init, };
Signature · 1 line
1.6.2.5
PATCH 5/6 ib700: move timer to IB700State
In reply to Juan Quintela--- hw/wdt_ib700.c | 23 ++++++++++++++++------- 1 files changed, 16 insertions(+), 7 deletions(-)
hw/wdt_ib700.c +16 -7
@@ -37,17 +37,18 @@typedef struct IB700state {ISADevice dev; +QEMUTimer *timer; }IB700State ;/* This is the timer. We use a global here because the watchdog * code ensures there is only one watchdog (it is located at a fixed, * unchangable IO port, so there could only ever be one anyway). */ -static QEMUTimer *timer =NULL ;/* A write to this register enables the timer. */ static void ib700_write_enable_reg (void *vp,uint32_t addr,uint32_t data) { +IB700State *s = vp;static int time_map[] = {30 ,28 ,26 ,24 ,22 ,20 ,18 ,16 ,14 ,12 ,10 ,8 ,6 ,4 ,2 ,0
@@ -57,37 +58,45 @@ static void ib700_write_enable_reg(void *vp, uint32_t addr, uint32_t data)ib700_debug ("addr = %x, data = %x\n" , addr, data); timeout = (int64_t ) time_map[data &0xF ] *get_ticks_per_sec (); -qemu_mod_timer (timer,qemu_get_clock (vm_clock) + timeout); +qemu_mod_timer (s->timer,qemu_get_clock (vm_clock) + timeout); }/* A write (of any value) to this register disables the timer. */ static void ib700_write_disable_reg (void *vp,uint32_t addr,uint32_t data) { +IB700State *s = vp; +ib700_debug ("addr = %x, data = %x\n" , addr, data); -qemu_del_timer (timer); +qemu_del_timer (s->timer); }/* This is called when the watchdog expires. */ static void ib700_timer_expired (void *vp) { +IB700State *s = vp; +ib700_debug ("watchdog expired\n" );watchdog_perform_action (); -qemu_del_timer (timer); +qemu_del_timer (s->timer); }static void ib700_save (QEMUFile *f,void *vp) { -qemu_put_timer (f, timer); +IB700State *s = vp; + +qemu_put_timer (f, s->timer); }static int ib700_load (QEMUFile *f,void *vp,int version) { +IB700State *s = vp; +if (version !=0 )return -EINVAL ; -qemu_get_timer (f, timer); +qemu_get_timer (f, s->timer);return 0 ; }
@@ -96,7 +105,7 @@ static int wdt_ib700_init(ISADevice *dev) {IB700State *s =DO_UPCAST (IB700State, dev, dev); - timer =qemu_new_timer (vm_clock, ib700_timer_expired, s); + s->timer =qemu_new_timer (vm_clock, ib700_timer_expired, s);register_savevm ("ib700_wdt" ,-1 ,0 , ib700_save, ib700_load, s);register_ioport_write (0x441 ,2 ,1 , ib700_write_disable_reg, s);register_ioport_write (0x443 ,2 ,1 , ib700_write_enable_reg, s);
Signature · 1 line
1.6.2.5
PATCH 6/6 ib700: port to vmstate
In reply to Juan Quintela--- hw/wdt_ib700.c | 30 +++++++++++------------------- 1 files changed, 11 insertions(+), 19 deletions(-)
hw/wdt_ib700.c +11 -19
@@ -82,31 +82,23 @@ static void ib700_timer_expired(void *vp)qemu_del_timer (s->timer); } -static void ib700_save (QEMUFile *f,void *vp) -{ -IB700State *s = vp; - -qemu_put_timer (f, s->timer); -} - -static int ib700_load (QEMUFile *f,void *vp,int version) -{ -IB700State *s = vp; - -if (version !=0 ) -return -EINVAL ; - -qemu_get_timer (f, s->timer); - -return 0 ; -} +static const VMStateDescription vmstate_ib700 = { + .name ="ib700_wdt" , + .version_id =0 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { +VMSTATE_TIMER (timer, IB700State), +VMSTATE_END_OF_LIST () + } +};static int wdt_ib700_init (ISADevice *dev) {IB700State *s =DO_UPCAST (IB700State, dev, dev); s->timer =qemu_new_timer (vm_clock, ib700_timer_expired, s); -register_savevm ("ib700_wdt" ,-1 ,0 , ib700_save, ib700_load, s); +vmstate_register (-1 , &vmstate_ib700, s);register_ioport_write (0x441 ,2 ,1 , ib700_write_disable_reg, s);register_ioport_write (0x443 ,2 ,1 , ib700_write_enable_reg, s);
Signature · 1 line
1.6.2.5
[Qemu-devel] Re: [PATCH 1/6] wdt_i6300esb: port to vmstate
In reply to Juan QuintelaQuoted 5 lines · Juan Quintela
Signed-off-by Juan Quintela <[email protected]>--- hw/wdt_i6300esb.c | 67 ++++++++++++++++++---------------------------------- 1 files changed, 23 insertions(+), 44 deletions(-)
As far as I understand the vmstate API, this looks like a straightforward conversion, so ACK.
Rich.
Signature · 4 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
[Qemu-devel] Re: [PATCH 2/6] wdt_i6300esb: remove useless casts from void *
In reply to Juan QuintelaReview
Quoted 4 lines · Juan Quintela
Signed-off-by Juan Quintela <[email protected]>(quoted diff) +1
-1- I6300State *d = (I6300State *) vp; + I6300State *d = vp;
[etc]
Obvious changes, ACK.
Rich.
Signature · 4 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/
[Qemu-devel] Re: [PATCH 3/6] wdt_i6300esb: move PCI_DEVICE_IDE_INTEL_ESB_9 to pci_ids.h
In reply to Juan QuintelaQuoted 36 lines · Juan Quintela
Signed-off-by Juan Quintela <[email protected]>--- hw/pci_ids.h | 1 + hw/wdt_i6300esb.c | 4 ---- 2 files changed, 1 insertions(+), 4 deletions(-)hw/pci_ids.h +1
-0@@ -88,6 +88,7 @@#define PCI_VENDOR_ID_INTEL 0x8086#define PCI_DEVICE_ID_INTEL_82441 0x1237#define PCI_DEVICE_ID_INTEL_82801AA_5 0x2415 +#define PCI_DEVICE_ID_INTEL_ESB_9 0x25ab#define PCI_DEVICE_ID_INTEL_82371SB_0 0x7000#define PCI_DEVICE_ID_INTEL_82371SB_1 0x7010#define PCI_DEVICE_ID_INTEL_82371SB_2 0x7020hw/wdt_i6300esb.c +0
-4@@ -36,10 +36,6 @@#define i6300esb_debug (fs,...)#endif -#ifndef PCI_DEVICE_ID_INTEL_ESB_9 -#define PCI_DEVICE_ID_INTEL_ESB_9 0x25ab -#endif -/* PCI configuration registers */ #define ESB_CONFIG_REG 0x60/* Config register */ #define ESB_LOCK_REG 0x68/* WDT lock register */ Signature · 1 line
1.6.2.5
Ah ha, yes, I was looking for the proper place to put that define (I thought it was in a Linux / system header file).
ACK.
Rich.
Signature · 4 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/
[Qemu-devel] Re: [PATCH 4/6] ib700: Introduce IB700State
In reply to Juan QuintelaOn Thu, Oct 15, 2009 at 01:40:00AM +0200, Juan Quintela wrote:
[...]
Obvious, straightforward transformation.
ACK.
Rich.
Signature · 4 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
[Qemu-devel] Re: [PATCH 5/6] ib700: move timer to IB700State
In reply to Juan QuintelaQuoted 2 lines · Juan Quintela
Signed-off-by Juan Quintela <[email protected]>
[...]
Simple clean-up, removes a global variable, and the fact that the device registers a global port should ensure we can't have more than one of them anyway.
ACK.
Rich.
Signature · 4 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
[Qemu-devel] Re: [PATCH 6/6] ib700: port to vmstate
In reply to Juan QuintelaQuoted 2 lines · Juan Quintela
Signed-off-by Juan Quintela <[email protected]>
As for patch 1/6, as far as I understand the VMState API, this looks like a simple, straightforward translation.
ACK.
Rich.
Signature · 4 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://et.redhat.com/~rjones/libguestfs/ See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html