Configurable PCI device addresses
cover Configurable PCI device addresses
This patch series makes PCI device addresses configurable for a number of devices. For now, I just covered the ones I consider important and/or where the change is somewhat invasive.
Why is a configurable PCI device address useful? Currently, QEMU assigns a few device addresses statically, and the rest dynamically on a first come, first serve basis[*]. If you add or remove a device, all devices registering later change address. I'm told a certain operating system that can't be named in polite company can get rather upset about that.
Making the device address configurable looks like the simplest solution to this problem. Only users who really mind changing addresses have to deal with the new configuration parameter.
I started with Izik's proposal to "allow setting static slot values for pci devices from the command line", see
http://lists.gnu.org/archive/html/qemu-devel/2008-01/msg00601.html http://lists.gnu.org/archive/html/qemu-devel/2007-11/msg00620.html
but ended up doing it quite differently.
I'm just soliciting comments. I do *not* ask for a commit of anything right now.
The patch series consists of these parts:
[1/9] PCI device registration helpers
[2/9] Clean up handling of name=value,... part of -vga option argument [3/9] Support pci=... in option argument of -vga
[4/9] Convert virtio_init_pci() to pci_register_device_2() [5/9] Support pci=... in option argument of -net nic
[6/9] Make drives_opt[] accessible from device initialization [7/9] Support pci=... in option argument of -drive if=virtio [8/9] New option -audio as a more flexible alternative to -soundhw [9/9] Support pci=... in option argument of -audio
Overall diffstat:
hw/ac97.c | 11 +--- hw/audiodev.h | 4 +- hw/cirrus_vga.c | 6 +- hw/e1000.c | 6 +- hw/eepro100.c | 19 ++++---- hw/es1370.c | 11 +--- hw/mips_malta.c | 17 +++---- hw/ne2000.c | 7 +-- hw/pc.c | 23 ++++------ hw/pc.h | 11 +--- hw/pci.c | 109 ++++++++++++++++++++++++++++++++++++++++++++-- hw/pci.h | 25 ++++++---- hw/pcnet.c | 6 +- hw/ppc440_bamboo.c | 5 +- hw/ppc_chrp.c | 4 +- hw/ppc_oldworld.c | 4 +- hw/ppc_prep.c | 4 +- hw/r2d.c | 8 ++-- hw/realview.c | 2 +- hw/rtl8139.c | 7 +-- hw/sun4u.c | 4 +- hw/versatilepb.c | 2 +- hw/vga.c | 40 ++++++++-------- hw/virtio-balloon.c | 2 +- hw/virtio-blk.c | 4 +- hw/virtio-blk.h | 2 +- hw/virtio-console.c | 2 +- hw/virtio-net.c | 5 +- hw/virtio-net.h | 2 +- hw/virtio.c | 5 +- hw/virtio.h | 2 +- hw/vmware_vga.c | 7 ++- net.c | 1 + net.h | 1 + sysemu.h | 13 +++++- vl.c | 120 ++++++++++++++++++++++++++++++++------------------- 36 files changed, 315 insertions(+), 186 deletions(-)
[*] To be precise: it assigns the dev.func part dynamically. The domain:bus: part is still statically assigned.
PATCH 1/9 PCI device registration helpers
From: Markus Armbruster <[email protected]>
Registering a device with a PCI device address given as pci=... in the common name=value,... option argument involves several steps: extract the device address, parse it, find the PICBus, call pci_register_device(). Put code for that in one place, namelt the new helper function pci_register_device_2(). Yes, the name is stupid, and is subject to change.
This code parses full PCI device addresses. It then rejects domains other than zero, because these are not supported in QEMU. FIXME it lets you specify .func, which is most probably inappropriate.
--- hw/pci.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/pci.h | 6 ++++ 2 files changed, 108 insertions(+), 0 deletions(-)
hw/pci.c +102 -0
@@ -26,6 +26,7 @@#include "console.h" #include "net.h" #include "virtio-net.h" +#include "sysemu.h" //#define DEBUG_PCI
@@ -158,6 +159,97 @@ static int pci_set_default_subsystem_id(PCIDevice *pci_dev)return 0 ; } +/* +* Parse [[<domain>:]<bus>:]<dev>[.<func>], return -1 on error +*/ +int pci_parse_devaddr (const char *addr,int *domp,int *busp,int *devfnp) +{ +const char *p; +char *e; +unsigned long val; +unsigned long dom =0 , bus =0 ; +unsigned slot; +unsigned func =0 ; + + p = addr; + val =strtoul (p, &e,16 ); +if (e == p) +return -1 ; +if (*e ==':' ) { + bus = val; + p = e +1 ; + val =strtoul (p, &e,16 ); +if (e == p) +return -1 ; +if (*e ==':' ) { + dom = bus; + bus = val; + p = e +1 ; + val =strtoul (p, &e,16 ); +if (e == p) +return -1 ; + } + } + +if (dom >0xffff || bus >0xff || val >0x1f ) +return -1 ; + slot = val; + +if (*e =='.' ) { + p = e +1 ; + val =strtoul (p, &e,16 ); +if (e == p || val >7 || *e !='\0' ) +return -1 ; + func = val; + } + +if (*e) +return -1 ; + + *domp = dom; + *busp = bus; + *devfnp = (slot <<3 ) | func; +return 0 ; +} + +PCIDevice *pci_register_device_2 (const char *name,const char *opts, +int instance_size, +PCIConfigReadFunc *config_read, +PCIConfigWriteFunc *config_write) +{ +char devaddr[32 ]; +int dom, bus_num, devfn; +PCIBus *bus; +PCIDevice *dev; + +if (get_param_value (devaddr,sizeof (devaddr),"pci" , opts)) { +if (pci_parse_devaddr (devaddr, &dom, &bus_num, &devfn) <0 ) { +fprintf (stderr,"Bad PCI device address %s for %s" , + devaddr, name); +return NULL ; + } + }else { + dom = bus_num =0 ; + devfn =-1 ; + } + +/* Note: QEMU doesn't implement domains other than 0 */ +if (dom !=0 || (bus =pci_find_bus (bus_num)) ==NULL ) { +fprintf (stderr,"PCI device address %s not supported for %s" , + devaddr, name); +return NULL ; + } + + dev =pci_register_device (bus, name, instance_size, devfn, + config_read, config_write); +if (!dev) { +fprintf (stderr,"Could not set up PCI device %s" , name); +return NULL ; + } + +return dev; +} +/* -1 for devfn means auto assign */ PCIDevice *pci_register_device(PCIBus *bus, const char *name, int instance_size, int devfn,
@@ -713,6 +805,16 @@ static void pci_bridge_write_config(PCIDevice *d,pci_default_write_config (d, address, val, len); } +PCIBus *pci_find_bus (int bus_num) +{ +PCIBus *bus = first_bus; + +while (bus && bus->bus_num != bus_num) + bus = bus->next; + +return bus; +} +PCIBus *pci_bridge_init (PCIBus *bus,int devfn,uint32_t id,pci_map_irq_fn map_irq,const char *name) {
hw/pci.h +6 -0
@@ -101,6 +101,10 @@ PCIDevice *pci_register_device(PCIBus *bus, const char *name, int instance_size, int devfn, PCIConfigReadFunc *config_read, PCIConfigWriteFunc *config_write); +PCIDevice *pci_register_device_2 (const char *name,const char *opts, +int instance_size, +PCIConfigReadFunc *config_read, +PCIConfigWriteFunc *config_write); void pci_register_io_region(PCIDevice *pci_dev, int region_num, uint32_t size, int type,
@@ -112,6 +116,7 @@ void pci_default_write_config(PCIDevice *d, uint32_t address, uint32_t val, int len);void pci_device_save (PCIDevice *s,QEMUFile *f);int pci_device_load (PCIDevice *s,QEMUFile *f); +int pci_parse_devaddr (const char *addr,int *domain,int *bus,int *devfn);typedef void (*pci_set_irq_fn )(qemu_irq *pic,int irq_num,int level);typedef int (*pci_map_irq_fn )(PCIDevice *pci_dev,int irq_num);
@@ -124,6 +129,7 @@ void pci_data_write(void *opaque, uint32_t addr, uint32_t val, int len);uint32_t pci_data_read (void *opaque,uint32_t addr,int len);int pci_bus_num (PCIBus *s);void pci_for_each_device (int bus_num,void (*fn)(PCIDevice *d)); +PCIBus *pci_find_bus (int bus_num);void pci_info (void ); PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint32_t id,
Signature · 1 line
1.6.0.6
PATCH 2/9 Clean up handling of name=value, ... part of -vga option argument
In reply to Markus ArmbrusterFrom: Markus Armbruster <[email protected]>
Move interpretation of the option argument from select_vgahw() into the device initialization functions. The only one that's currently interested is vga_common_init(). Use get_param_value() there instead of the special purpose code select_vgahw() used to use. The move permits hiding vga_retrace_method & friends in vga.c, so do that.
--- hw/pc.h | 7 +------ hw/vga.c | 34 +++++++++++++++++----------------- vl.c | 19 +++++-------------- 3 files changed, 23 insertions(+), 37 deletions(-)
hw/pc.h +1 -6
@@ -119,12 +119,7 @@ extern PCIDevice *piix4_dev;int piix4_init (PCIBus *bus,int devfn);/* vga.c */ -enum vga_retrace_method { -VGA_RETRACE_DUMB , -VGA_RETRACE_PRECISE -}; - -extern enum vga_retrace_method vga_retrace_method; +extern const char *vga_opts;#ifndef TARGET_SPARC #define VGA_RAM_SIZE (8192 * 1024)
hw/vga.c +17 -17
@@ -29,6 +29,7 @@#include "pixel_ops.h" #include "qemu-timer.h" #include "kvm.h" +#include "sysemu.h" //#define DEBUG_VGA //#define DEBUG_VGA_MEM
@@ -1922,13 +1923,8 @@ void vga_reset(void *opaque)memset (s->invalidated_y_table,'\0' ,sizeof (s->invalidated_y_table));memset (s->last_palette,'\0' ,sizeof (s->last_palette));memset (s->last_ch_attr,'\0' ,sizeof (s->last_ch_attr)); -switch (vga_retrace_method) { -case VGA_RETRACE_DUMB : -break ; -case VGA_RETRACE_PRECISE : +if (s->retrace == vga_precise_retrace)memset (&s->retrace_info,0 ,sizeof (s->retrace_info)); -break ; - } }#define TEXTMODE_X (x) ((x) % width)
@@ -2257,7 +2253,8 @@ static void vga_map(PCIDevice *pci_dev, int region_num,void vga_common_init (VGAState *s,uint8_t *vga_ram_base,ram_addr_t vga_ram_offset,int vga_ram_size) { -int i, j, v, b; +int i, j, v, b, precise_retrace; +char buf[32 ];for (i =0 ;i <256 ; i++) { v =0 ;
@@ -2292,16 +2289,19 @@ void vga_common_init(VGAState *s, uint8_t *vga_ram_base, s->invalidate = vga_invalidate_display; s->screen_dump = vga_screen_dump; s->text_update = vga_update_text; -switch (vga_retrace_method) { -case VGA_RETRACE_DUMB : - s->retrace = vga_dumb_retrace; - s->update_retrace_info = vga_dumb_update_retrace_info; -break ; - -case VGA_RETRACE_PRECISE : - s->retrace = vga_precise_retrace; - s->update_retrace_info = vga_precise_update_retrace_info; -break ; + precise_retrace =0 ; +if (get_param_value (buf,sizeof (buf),"retrace" , vga_opts)) { +if (!strcmp (buf,"precise" )) + precise_retrace =1 ; +else if (strcmp (buf,"dumb" )) +fprintf (stderr,"Unknown VGA retrace=%s ignored\n" , buf); + } +if (precise_retrace) { + s->retrace = vga_precise_retrace; + s->update_retrace_info = vga_precise_update_retrace_info; + }else { + s->retrace = vga_dumb_retrace; + s->update_retrace_info = vga_dumb_update_retrace_info; }vga_reset (s); }
vl.c +5 -14
@@ -186,7 +186,6 @@ static IOPortWriteFunc *ioport_write_table[3][MAX_IOPORTS];DriveInfo drives_table[MAX_DRIVES +1 ];int nb_drives;static int vga_ram_size; -enum vga_retrace_method vga_retrace_method =VGA_RETRACE_DUMB ;static DisplayState *display_state;int nographic;static int curses;
@@ -202,6 +201,7 @@ static int rtc_date_offset = -1; /* -1 means no change */int cirrus_vga_enabled =1 ;int std_vga_enabled =0 ;int vmsvga_enabled =0 ; +const char *vga_opts ="" ;#ifdef TARGET_SPARC int graphic_width =1024 ;int graphic_height =768 ;
@@ -4430,19 +4430,10 @@ static void select_vgahw (const char *p)fprintf (stderr,"Unknown vga type: %s\n" , p);exit (1 ); } -while (*opts) { -const char *nextopt; - -if (strstart (opts,",retrace=" , &nextopt)) { - opts = nextopt; -if (strstart (opts,"dumb" , &nextopt)) - vga_retrace_method =VGA_RETRACE_DUMB ; -else if (strstart (opts,"precise" , &nextopt)) - vga_retrace_method =VGA_RETRACE_PRECISE ; -else goto invalid_vga; - }else goto invalid_vga; - opts = nextopt; - } +if (opts[0 ] ==',' ) + vga_opts = opts +1 ; +else if (opts[0 ]) + goto invalid_vga; }#ifdef _WIN32
Signature · 1 line
1.6.0.6
PATCH 3/9 Support pci=... in option argument of -vga
In reply to Markus ArmbrusterFrom: Markus Armbruster <[email protected]>
--- hw/cirrus_vga.c | 6 +++--- hw/mips_malta.c | 2 +- hw/pc.c | 7 +++---- hw/pc.h | 4 ++-- hw/pci.h | 2 +- hw/ppc_chrp.c | 2 +- hw/ppc_oldworld.c | 2 +- hw/ppc_prep.c | 2 +- hw/sun4u.c | 2 +- hw/vga.c | 6 +++--- hw/vmware_vga.c | 7 ++++--- 11 files changed, 21 insertions(+), 21 deletions(-)
hw/cirrus_vga.c +3 -3
@@ -3339,7 +3339,7 @@ static void cirrus_pci_mmio_map(PCIDevice *d, int region_num, s->cirrus_mmio_io_addr); } -void pci_cirrus_vga_init (PCIBus *bus,uint8_t *vga_ram_base, +void pci_cirrus_vga_init (uint8_t *vga_ram_base,ram_addr_t vga_ram_offset,int vga_ram_size) {PCICirrusVGAState *d;
@@ -3350,9 +3350,9 @@ void pci_cirrus_vga_init(PCIBus *bus, uint8_t *vga_ram_base, device_id =CIRRUS_ID_CLGD5446 ;/* setup PCI configuration registers */ - d = (PCICirrusVGAState *)pci_register_device (bus,"Cirrus VGA" , + d = (PCICirrusVGAState *)pci_register_device_2 ("Cirrus VGA" , vga_opts,sizeof (PCICirrusVGAState), --1 ,NULL ,NULL ); +NULL ,NULL ); pci_conf = d->dev.config; pci_conf[0x00 ] = (uint8_t ) (PCI_VENDOR_CIRRUS &0xff ); pci_conf[0x01 ] = (uint8_t ) (PCI_VENDOR_CIRRUS >>8 );
hw/mips_malta.c +1 -1
@@ -935,7 +935,7 @@ void mips_malta_init (ram_addr_t ram_size, int vga_ram_size,network_init (pci_bus);/* Optional PCI video card */ -pci_cirrus_vga_init (pci_bus, phys_ram_base + ram_size, +pci_cirrus_vga_init (phys_ram_base + ram_size, ram_size, vga_ram_size); }
hw/pc.c +3 -4
@@ -945,8 +945,7 @@ vga_bios_error:if (cirrus_vga_enabled) {if (pci_enabled) { -pci_cirrus_vga_init (pci_bus, - phys_ram_base + vga_ram_addr, +pci_cirrus_vga_init (phys_ram_base + vga_ram_addr, vga_ram_addr, vga_ram_size); }else { isa_cirrus_vga_init(phys_ram_base + vga_ram_addr,
@@ -954,13 +953,13 @@ vga_bios_error: } }else if (vmsvga_enabled) {if (pci_enabled) -pci_vmsvga_init (pci_bus, phys_ram_base + vga_ram_addr, +pci_vmsvga_init (phys_ram_base + vga_ram_addr, vga_ram_addr, vga_ram_size);else fprintf (stderr,"%s: vmware_vga: no PCI bus\n" , __FUNCTION__); }else if (std_vga_enabled) {if (pci_enabled) { -pci_vga_init (pci_bus, phys_ram_base + vga_ram_addr, +pci_vga_init (phys_ram_base + vga_ram_addr, vga_ram_addr, vga_ram_size,0 ,0 ); }else { isa_vga_init(phys_ram_base + vga_ram_addr,
hw/pc.h +2 -2
@@ -129,7 +129,7 @@ extern const char *vga_opts;int isa_vga_init (uint8_t *vga_ram_base,unsigned long vga_ram_offset,int vga_ram_size); -int pci_vga_init (PCIBus *bus,uint8_t *vga_ram_base, +int pci_vga_init (uint8_t *vga_ram_base,unsigned long vga_ram_offset,int vga_ram_size,unsigned long vga_bios_offset,int vga_bios_size); int isa_vga_mm_init(uint8_t *vga_ram_base,
@@ -138,7 +138,7 @@ int isa_vga_mm_init(uint8_t *vga_ram_base, int it_shift);/* cirrus_vga.c */ -void pci_cirrus_vga_init (PCIBus *bus,uint8_t *vga_ram_base, +void pci_cirrus_vga_init (uint8_t *vga_ram_base,ram_addr_t vga_ram_offset,int vga_ram_size);void isa_cirrus_vga_init (uint8_t *vga_ram_base,ram_addr_t vga_ram_offset,int vga_ram_size);
hw/pci.h +1 -1
@@ -141,7 +141,7 @@ void lsi_scsi_attach(void *opaque, BlockDriverState *bd, int id);void *lsi_scsi_init (PCIBus *bus,int devfn);/* vmware_vga.c */ -void pci_vmsvga_init (PCIBus *bus,uint8_t *vga_ram_base, +void pci_vmsvga_init (uint8_t *vga_ram_base,unsigned long vga_ram_offset,int vga_ram_size);/* usb-uhci.c */
hw/ppc_chrp.c +1 -1
@@ -256,7 +256,7 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size, pic =openpic_init (NULL , &pic_mem_index, smp_cpus, openpic_irqs,NULL ); pci_bus =pci_pmac_init (pic);/* init basic PC hardware */ -pci_vga_init (pci_bus, phys_ram_base + ram_size, +pci_vga_init (phys_ram_base + ram_size, ram_size, vga_ram_size, vga_bios_offset, vga_bios_size);
hw/ppc_oldworld.c +1 -1
@@ -296,7 +296,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size, int vga_ram_size, } pic =heathrow_pic_init (&pic_mem_index,1 , heathrow_irqs); pci_bus =pci_grackle_init (0xfec00000 , pic); -pci_vga_init (pci_bus, phys_ram_base + vga_ram_offset, +pci_vga_init (phys_ram_base + vga_ram_offset, vga_ram_offset, vga_ram_size, vga_bios_offset, vga_bios_size);
hw/ppc_prep.c +1 -1
@@ -655,7 +655,7 @@ static void ppc_prep_init (ram_addr_t ram_size, int vga_ram_size,cpu_register_physical_memory (0x80000000 ,0x00800000 , PPC_io_memory);/* init basic PC hardware */ -pci_vga_init (pci_bus, phys_ram_base + ram_size, ram_size, +pci_vga_init (phys_ram_base + ram_size, ram_size, vga_ram_size,0 ,0 );// openpic = openpic_init(0x00000000, 0xF0000000, 1); // pit = pit_init(0x40, i8259[0]);
hw/sun4u.c +1 -1
@@ -508,7 +508,7 @@ static void sun4uv_init(ram_addr_t RAM_size, int vga_ram_size, &pci_bus3); isa_mem_base =VGA_BASE ; vga_ram_offset =qemu_ram_alloc (vga_ram_size); -pci_vga_init (pci_bus, phys_ram_base + vga_ram_offset, +pci_vga_init (phys_ram_base + vga_ram_offset, vga_ram_offset, vga_ram_size,0 ,0 );
hw/vga.c +3 -3
@@ -2481,7 +2481,7 @@ int isa_vga_mm_init(uint8_t *vga_ram_base,return 0 ; } -int pci_vga_init (PCIBus *bus,uint8_t *vga_ram_base, +int pci_vga_init (uint8_t *vga_ram_base,unsigned long vga_ram_offset,int vga_ram_size,unsigned long vga_bios_offset,int vga_bios_size) {
@@ -2489,9 +2489,9 @@ int pci_vga_init(PCIBus *bus, uint8_t *vga_ram_base,VGAState *s;uint8_t *pci_conf; - d = (PCIVGAState *)pci_register_device (bus,"VGA" , + d = (PCIVGAState *)pci_register_device_2 ("VGA" , vga_opts,sizeof (PCIVGAState), --1 ,NULL ,NULL ); +NULL ,NULL );if (!d)return -1 ; s = &d->vga_state;
hw/vmware_vga.c +4 -3
@@ -24,6 +24,7 @@#include "hw.h" #include "console.h" #include "pci.h" +#include "pc.h" #define VERBOSE #define EMBED_STDVGA
@@ -1214,15 +1215,15 @@ static void pci_vmsvga_map_mem(PCIDevice *pci_dev, int region_num,#define PCI_CLASS_SUB_VGA 0x00#define PCI_CLASS_HEADERTYPE_00h 0x00 -void pci_vmsvga_init (PCIBus *bus,uint8_t *vga_ram_base, +void pci_vmsvga_init (uint8_t *vga_ram_base,unsigned long vga_ram_offset,int vga_ram_size) {struct pci_vmsvga_state_s *s;/* Setup PCI configuration */ s = (struct pci_vmsvga_state_s *) -pci_register_device (bus,"QEMUware SVGA" , -sizeof (struct pci_vmsvga_state_s ),-1 ,0 ,0 ); +pci_register_device_2 ("QEMUware SVGA" , vga_opts, +sizeof (struct pci_vmsvga_state_s ),0 ,0 ); s->card.config[PCI_VENDOR_ID ] =PCI_VENDOR_ID_VMWARE &0xff ; s->card.config[PCI_VENDOR_ID +1 ] =PCI_VENDOR_ID_VMWARE >>8 ; s->card.config[PCI_DEVICE_ID ] =SVGA_PCI_DEVICE_ID &0xff ;
Signature · 1 line
1.6.0.6
PATCH 4/9 Convert virtio_init_pci() to pci_register_device_2()
In reply to Markus ArmbrusterFrom: Markus Armbruster <[email protected]>
This is in preparation of pci=... support for virtio devices.
--- hw/virtio-balloon.c | 2 +- hw/virtio-blk.c | 2 +- hw/virtio-console.c | 2 +- hw/virtio-net.c | 3 ++- hw/virtio.c | 5 ++--- hw/virtio.h | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-)
hw/virtio-balloon.c +1 -1
@@ -171,7 +171,7 @@ void *virtio_balloon_init(PCIBus *bus) {VirtIOBalloon *s; - s = (VirtIOBalloon *)virtio_init_pci(bus, "virtio-balloon", + s = (VirtIOBalloon *)virtio_init_pci("virtio-balloon", "", PCI_VENDOR_ID_REDHAT_QUMRANET, PCI_DEVICE_ID_VIRTIO_BALLOON, 0, VIRTIO_ID_BALLOON,
hw/virtio-blk.c +1 -1
@@ -224,7 +224,7 @@ void *virtio_blk_init(PCIBus *bus, BlockDriverState *bs)int cylinders, heads, secs;static int virtio_blk_id; - s = (VirtIOBlock *)virtio_init_pci(bus, "virtio-blk", + s = (VirtIOBlock *)virtio_init_pci("virtio-blk", "", PCI_VENDOR_ID_REDHAT_QUMRANET, PCI_DEVICE_ID_VIRTIO_BLOCK, 0, VIRTIO_ID_BLOCK,
hw/virtio-console.c +1 -1
@@ -125,7 +125,7 @@ void *virtio_console_init(PCIBus *bus, CharDriverState *chr) {VirtIOConsole *s; - s = (VirtIOConsole *)virtio_init_pci(bus, "virtio-console", + s = (VirtIOConsole *)virtio_init_pci("virtio-console", "", 6900, 0x1003, 0, VIRTIO_ID_CONSOLE, 0x03, 0x80, 0x00,
hw/virtio-net.c +2 -1
@@ -320,7 +320,8 @@ void virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)VirtIONet *n;static int virtio_net_id; - n = (VirtIONet *)virtio_init_pci(bus, "virtio-net", 6900, 0x1000, + n = (VirtIONet *)virtio_init_pci("virtio-net", "", + 6900, 0x1000, 0, VIRTIO_ID_NET, 0x02, 0x00, 0x00, sizeof(struct virtio_net_config),
hw/virtio.c +2 -3
@@ -805,7 +805,7 @@ void virtio_load(VirtIODevice *vdev, QEMUFile *f)virtio_update_irq (vdev); } -VirtIODevice *virtio_init_pci(PCIBus *bus, const char *name, +VirtIODevice *virtio_init_pci(const char *name, const char *opts, uint16_t vendor, uint16_t device, uint16_t subvendor, uint16_t subdevice, uint8_t class_code, uint8_t subclass_code,
@@ -817,8 +817,7 @@ VirtIODevice *virtio_init_pci(PCIBus *bus, const char *name,uint8_t *config;uint32_t size; - pci_dev =pci_register_device (bus, name, struct_size, --1 ,NULL ,NULL ); + pci_dev =pci_register_device_2 (name, opts, struct_size,NULL ,NULL );if (!pci_dev)return NULL ;
hw/virtio.h +1 -1
@@ -89,7 +89,7 @@ struct VirtIODeviceVirtQueue *vq; }; -VirtIODevice *virtio_init_pci(PCIBus *bus, const char *name, +VirtIODevice *virtio_init_pci(const char *name, const char *opts, uint16_t vendor, uint16_t device, uint16_t subvendor, uint16_t subdevice, uint8_t class_code, uint8_t subclass_code,
Signature · 1 line
1.6.0.6
PATCH 5/9 Support pci=... in option argument of -net nic
In reply to Markus ArmbrusterFrom: Markus Armbruster <[email protected]>
FIXME: the code registers two NICs with fixed device addresses. The patch preserves that, but it's a disgusting hack.
--- hw/e1000.c | 6 +++--- hw/eepro100.c | 19 +++++++++---------- hw/mips_malta.c | 9 ++++----- hw/ne2000.c | 7 +++---- hw/pc.c | 2 +- hw/pci.c | 7 +++---- hw/pci.h | 17 ++++++++--------- hw/pcnet.c | 6 +++--- hw/ppc440_bamboo.c | 2 +- hw/ppc_chrp.c | 2 +- hw/ppc_oldworld.c | 2 +- hw/ppc_prep.c | 2 +- hw/r2d.c | 8 ++++---- hw/realview.c | 2 +- hw/rtl8139.c | 7 +++---- hw/sun4u.c | 2 +- hw/versatilepb.c | 2 +- hw/virtio-net.c | 4 ++-- hw/virtio-net.h | 2 +- net.c | 1 + net.h | 1 + 21 files changed, 53 insertions(+), 57 deletions(-)
hw/e1000.c +3 -3
@@ -1035,7 +1035,7 @@ e1000_mmio_map(PCIDevice *pci_dev, int region_num, }void -pci_e1000_init (PCIBus *bus,NICInfo *nd,int devfn) +pci_e1000_init (NICInfo *nd) {E1000State *d;uint8_t *pci_conf;
@@ -1043,8 +1043,8 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn)static const char info_str[] ="e1000" ;int i; - d = (E1000State *)pci_register_device (bus,"e1000" , -sizeof (E1000State), devfn,NULL ,NULL ); + d = (E1000State *)pci_register_device_2 ("e1000" , nd->opts, +sizeof (E1000State),NULL ,NULL ); pci_conf = d->dev.config;memset (pci_conf,0 ,256 );
hw/eepro100.c +9 -10
@@ -1736,16 +1736,15 @@ static void nic_save(QEMUFile * f, void *opaque)qemu_put_buffer (f, s->configuration,sizeof (s->configuration)); } -static void nic_init (PCIBus * bus,NICInfo * nd, -const char *name,uint32_t device) +static void nic_init (NICInfo * nd,const char *name,uint32_t device) {PCIEEPRO100State *d;EEPRO100State *s;logout ("\n" ); - d = (PCIEEPRO100State *)pci_register_device (bus, name, -sizeof (PCIEEPRO100State),-1 , + d = (PCIEEPRO100State *)pci_register_device_2 (name, nd->opts, +sizeof (PCIEEPRO100State),NULL ,NULL ); s = &d->eepro100;
@@ -1786,20 +1785,20 @@ static void nic_init(PCIBus * bus, NICInfo * nd,register_savevm (name,-1 ,3 , nic_save, nic_load, s); } -void pci_i82551_init (PCIBus * bus,NICInfo * nd,int devfn) +void pci_i82551_init (NICInfo * nd) { -nic_init (bus, nd,"i82551" , i82551); +nic_init (nd,"i82551" , i82551);//~ uint8_t *pci_conf = d->dev.config; } -void pci_i82557b_init (PCIBus * bus,NICInfo * nd,int devfn) +void pci_i82557b_init (NICInfo * nd) { -nic_init (bus, nd,"i82557b" , i82557B); +nic_init (nd,"i82557b" , i82557B); } -void pci_i82559er_init (PCIBus * bus,NICInfo * nd,int devfn) +void pci_i82559er_init (NICInfo * nd) { -nic_init (bus, nd,"i82559er" , i82559ER); +nic_init (nd,"i82559er" , i82559ER); }/* eof */
hw/mips_malta.c +4 -5
@@ -483,19 +483,18 @@ static void audio_init (PCIBus *pci_bus)#endif /* Network support */ -static void network_init (PCIBus *pci_bus) +static void network_init (void ) {int i;for (i =0 ; i < nb_nics; i++) {NICInfo *nd = &nd_table[i]; -int devfn =-1 ;if (i ==0 && (!nd->model ||strcmp (nd->model,"pcnet" ) ==0 ))/* The malta board has a PCNet card using PCI SLOT 11 */ - devfn =88 ; + nd->opts ="pci=11" ;/* FIXME disgusting hack */ -pci_nic_init (pci_bus, nd, devfn,"pcnet" ); +pci_nic_init (nd,"pcnet" ); } }
@@ -932,7 +931,7 @@ void mips_malta_init (ram_addr_t ram_size, int vga_ram_size,#endif /* Network card */ -network_init (pci_bus); +network_init ();/* Optional PCI video card */ pci_cirrus_vga_init(phys_ram_base + ram_size,
hw/ne2000.c +3 -4
@@ -779,15 +779,14 @@ static void ne2000_map(PCIDevice *pci_dev, int region_num,register_ioport_read (addr +0x1f ,1 ,1 , ne2000_reset_ioport_read, s); } -void pci_ne2000_init (PCIBus *bus,NICInfo *nd,int devfn) +void pci_ne2000_init (NICInfo *nd) {PCINE2000State *d;NE2000State *s;uint8_t *pci_conf; - d = (PCINE2000State *)pci_register_device (bus, -"NE2000" ,sizeof (PCINE2000State), - devfn, + d = (PCINE2000State *)pci_register_device_2 ("NE2000" , nd->opts, +sizeof (PCINE2000State),NULL ,NULL ); pci_conf = d->dev.config; pci_conf[0x00 ] =0xec ;// Realtek 8029
hw/pc.c +1 -1
@@ -1006,7 +1006,7 @@ vga_bios_error:if (!pci_enabled || (nd->model &&strcmp (nd->model,"ne2k_isa" ) ==0 ))pc_init_ne2k_isa (nd, i8259);else -pci_nic_init (pci_bus, nd,-1 ,"ne2k_pci" ); +pci_nic_init (nd,"ne2k_pci" ); }if (drive_get_max_bus (IF_IDE ) >=MAX_IDE_BUS ) {
hw/pci.c +3 -4
@@ -756,7 +756,7 @@ static const char * const pci_nic_models[] = {NULL }; -typedef void (*PCINICInitFn )(PCIBus *,NICInfo *,int ); +typedef void (*PCINICInitFn )(NICInfo *);static PCINICInitFn pci_nic_init_fns[] = { pci_ne2000_init,
@@ -771,8 +771,7 @@ static PCINICInitFn pci_nic_init_fns[] = { };/* Initialize a PCI NIC. */ -void pci_nic_init (PCIBus *bus,NICInfo *nd,int devfn, -const char *default_model) +void pci_nic_init (NICInfo *nd,const char *default_model) {int i;
@@ -780,7 +779,7 @@ void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn,for (i =0 ; pci_nic_models[i]; i++)if (strcmp (nd->model, pci_nic_models[i]) ==0 ) - pci_nic_init_fns[i](bus, nd, devfn); + pci_nic_init_fns[i](nd); } typedef struct {
hw/pci.h +8 -9
@@ -123,8 +123,7 @@ typedef int (*pci_map_irq_fn)(PCIDevice *pci_dev, int irq_num);PCIBus *pci_register_bus (pci_set_irq_fn set_irq,pci_map_irq_fn map_irq,qemu_irq *pic,int devfn_min,int nirq); -void pci_nic_init (PCIBus *bus,NICInfo *nd,int devfn, -const char *default_model); +void pci_nic_init (NICInfo *nd,const char *default_model);void pci_data_write (void *opaque,uint32_t addr,uint32_t val,int len);uint32_t pci_data_read (void *opaque,uint32_t addr,int len);int pci_bus_num (PCIBus *s);
@@ -153,23 +152,23 @@ void usb_ohci_init_pci(struct PCIBus *bus, int num_ports, int devfn);/* eepro100.c */ -void pci_i82551_init (PCIBus *bus,NICInfo *nd,int devfn); -void pci_i82557b_init (PCIBus *bus,NICInfo *nd,int devfn); -void pci_i82559er_init (PCIBus *bus,NICInfo *nd,int devfn); +void pci_i82551_init (NICInfo *nd); +void pci_i82557b_init (NICInfo *nd); +void pci_i82559er_init (NICInfo *nd);/* ne2000.c */ -void pci_ne2000_init (PCIBus *bus,NICInfo *nd,int devfn); +void pci_ne2000_init (NICInfo *nd);/* rtl8139.c */ -void pci_rtl8139_init (PCIBus *bus,NICInfo *nd,int devfn); +void pci_rtl8139_init (NICInfo *nd);/* e1000.c */ -void pci_e1000_init (PCIBus *bus,NICInfo *nd,int devfn); +void pci_e1000_init (NICInfo *nd);/* pcnet.c */ -void pci_pcnet_init (PCIBus *bus,NICInfo *nd,int devfn); +void pci_pcnet_init (NICInfo *nd);/* prep_pci.c */ PCIBus *pci_prep_init (qemu_irq *pic);
hw/pcnet.c +3 -3
@@ -1985,7 +1985,7 @@ static void pci_physical_memory_read(void *dma_opaque, target_phys_addr_t addr,cpu_physical_memory_read (addr, buf, len); } -void pci_pcnet_init (PCIBus *bus,NICInfo *nd,int devfn) +void pci_pcnet_init (NICInfo *nd) {PCNetState *d;uint8_t *pci_conf;
@@ -1995,8 +1995,8 @@ void pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn) sizeof(struct pcnet_RMD), sizeof(struct pcnet_TMD));#endif - d = (PCNetState *)pci_register_device (bus,"PCNet" ,sizeof (PCNetState), - devfn,NULL ,NULL ); + d = (PCNetState *)pci_register_device_2 ("PCNet" , nd->opts, +sizeof (PCNetState),NULL ,NULL ); pci_conf = d->dev.config;
hw/ppc440_bamboo.c +1 -1
@@ -126,7 +126,7 @@ static void bamboo_init(ram_addr_t ram_size, int vga_ram_size,for (i =0 ; i < nb_nics; i++) {/* There are no PCI NICs on the Bamboo board, but there are * PCI slots, so we can pick whatever default model we want. */ -pci_nic_init (pcibus, &nd_table[i],-1 ,"e1000" ); +pci_nic_init (&nd_table[i],"e1000" ); } }
hw/ppc_chrp.c +1 -1
@@ -267,7 +267,7 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size, serial_hds[0], serial_hds[1], ESCC_CLOCK, 4);for (i =0 ; i < nb_nics; i++) -pci_nic_init (pci_bus, &nd_table[i],-1 ,"ne2k_pci" ); +pci_nic_init (&nd_table[i],"ne2k_pci" );if (drive_get_max_bus (IF_IDE ) >=MAX_IDE_BUS ) {fprintf (stderr,"qemu: too many IDE bus\n" );
hw/ppc_oldworld.c +1 -1
@@ -304,7 +304,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size, int vga_ram_size, serial_hds[1], ESCC_CLOCK, 4);for (i =0 ; i < nb_nics; i++) -pci_nic_init (pci_bus, &nd_table[i],-1 ,"ne2k_pci" ); +pci_nic_init (&nd_table[i],"ne2k_pci" );/* First IDE channel is a CMD646 on the PCI bus */
hw/ppc_prep.c +1 -1
@@ -672,7 +672,7 @@ static void ppc_prep_init (ram_addr_t ram_size, int vga_ram_size,if (strcmp (nd_table[i].model,"ne2k_isa" ) ==0 ) {isa_ne2000_init (ne2000_io[i], i8259[ne2000_irq[i]], &nd_table[i]); }else { -pci_nic_init (pci_bus, &nd_table[i],-1 ,"ne2k_pci" ); +pci_nic_init (&nd_table[i],"ne2k_pci" ); } }
hw/r2d.c +4 -4
@@ -201,7 +201,6 @@ static void r2d_init(ram_addr_t ram_size, int vga_ram_size,struct SH7750State *s;ram_addr_t sdram_addr, sm501_vga_ram_addr;qemu_irq *irq; -PCIBus *pci;int i;if (!cpu_model)
@@ -219,7 +218,7 @@ static void r2d_init(ram_addr_t ram_size, int vga_ram_size,/* Register peripherals */ s =sh7750_init (env); irq =r2d_fpga_init (0x04000000 ,sh7750_irl (s)); - pci =sh_pci_register_bus (r2d_pci_set_irq, r2d_pci_map_irq, irq,0 ,4 ); +sh_pci_register_bus (r2d_pci_set_irq, r2d_pci_map_irq, irq,0 ,4 ); sm501_vga_ram_addr =qemu_ram_alloc (SM501_VRAM_SIZE ); sm501_init(0x10000000, sm501_vga_ram_addr, SM501_VRAM_SIZE,
@@ -230,9 +229,10 @@ static void r2d_init(ram_addr_t ram_size, int vga_ram_size, drives_table[drive_get_index(IF_IDE, 0, 0)].bdrv, NULL);/* NIC: rtl8139 on-board, and 2 slots. */ -pci_nic_init (pci, &nd_table[0 ],2 <<3 ,"rtl8139" ); + nd_table[0 ].opts ="pci=2" ;/* FIXME disgusting hack */ +pci_nic_init (&nd_table[0 ],"rtl8139" );for (i =1 ; i < nb_nics; i++) -pci_nic_init (pci, &nd_table[i],-1 ,"ne2k_pci" ); +pci_nic_init (&nd_table[i],"ne2k_pci" );/* Todo: register on board registers */ {
hw/realview.c +1 -1
@@ -126,7 +126,7 @@ static void realview_init(ram_addr_t ram_size, int vga_ram_size,smc91c111_init (nd,0x4e000000 , pic[28 ]); done_smc =1 ; }else { -pci_nic_init (pci_bus, nd,-1 ,"rtl8139" ); +pci_nic_init (nd,"rtl8139" ); } }
hw/rtl8139.c +3 -4
@@ -3414,15 +3414,14 @@ static void rtl8139_timer(void *opaque) }#endif /* RTL8139_ONBOARD_TIMER */ -void pci_rtl8139_init (PCIBus *bus,NICInfo *nd,int devfn) +void pci_rtl8139_init (NICInfo *nd) {PCIRTL8139State *d;RTL8139State *s;uint8_t *pci_conf; - d = (PCIRTL8139State *)pci_register_device (bus, -"RTL8139" ,sizeof (PCIRTL8139State), - devfn, + d = (PCIRTL8139State *)pci_register_device_2 ("RTL8139" , nd->opts, +sizeof (PCIRTL8139State),NULL ,NULL ); pci_conf = d->dev.config; pci_conf[0x00 ] =0xec ;/* Realtek 8139 */
hw/sun4u.c +1 -1
@@ -536,7 +536,7 @@ static void sun4uv_init(ram_addr_t RAM_size, int vga_ram_size, }for (i =0 ; i < nb_nics; i++) -pci_nic_init (pci_bus, &nd_table[i],-1 ,"ne2k_pci" ); +pci_nic_init (&nd_table[i],"ne2k_pci" ); irq =qemu_allocate_irqs (cpu_set_irq, env,MAX_PILS );if (drive_get_max_bus (IF_IDE ) >=MAX_IDE_BUS ) {
hw/versatilepb.c +1 -1
@@ -199,7 +199,7 @@ static void versatile_init(ram_addr_t ram_size, int vga_ram_size,smc91c111_init (nd,0x10010000 , sic[25 ]); done_smc =1 ; }else { -pci_nic_init (pci_bus, nd,-1 ,"rtl8139" ); +pci_nic_init (nd,"rtl8139" ); } }if (usb_enabled) {
hw/virtio-net.c +2 -2
@@ -315,12 +315,12 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)return 0 ; } -void virtio_net_init (PCIBus *bus,NICInfo *nd,int devfn) +void virtio_net_init (NICInfo *nd) {VirtIONet *n;static int virtio_net_id; - n = (VirtIONet *)virtio_init_pci("virtio-net", "", + n = (VirtIONet *)virtio_init_pci("virtio-net", nd->opts, 6900, 0x1000, 0, VIRTIO_ID_NET, 0x02, 0x00, 0x00,
hw/virtio-net.h +1 -1
@@ -80,6 +80,6 @@ struct virtio_net_hdr_mrg_rxbuf uint16_t num_buffers; /* Number of merged rx buffers */ }; -void virtio_net_init (PCIBus *bus,NICInfo *nd,int devfn); +void virtio_net_init (NICInfo *nd);#endif
net.c +1 -0
@@ -1581,6 +1581,7 @@ int net_client_init(const char *device, const char *p) } nd->vlan = vlan; nd->name = name; + nd->opts = p; name =NULL ; nb_nics++; vlan->nb_guest_devs++;
net.h +1 -0
@@ -63,6 +63,7 @@ struct NICInfo {uint8_t macaddr[6 ];const char *model;const char *name; +const char *opts;VLANState *vlan; };
Signature · 1 line
1.6.0.6
PATCH 6/9 Make drives_opt[] accessible from device initialization
In reply to Markus ArmbrusterFrom: Markus Armbruster <[email protected]>
This is in preparation of pci=... support for block devices.
--- sysemu.h | 10 ++++++++++ vl.c | 7 ++----- 2 files changed, 12 insertions(+), 5 deletions(-)
sysemu.h +10 -0
@@ -134,6 +134,7 @@ typedef struct DriveInfo {int bus;int unit;char serial[21 ]; +int drive_opt_idx; } DriveInfo;#define MAX_IDE_DEVS 2
@@ -143,6 +144,15 @@ typedef struct DriveInfo {extern int nb_drives;extern DriveInfo drives_table[MAX_DRIVES +1 ]; +struct drive_opt { +const char *file; +char opt[1024 ]; +int used; +}; + +extern struct drive_opt drives_opt[MAX_DRIVES ]; +extern int nb_drives_opt; +extern int drive_get_index (BlockInterfaceType type,int bus,int unit);extern int drive_get_max_bus (BlockInterfaceType type);extern const char *drive_get_serial (BlockDriverState *bdrv);
vl.c +2 -5
@@ -246,11 +246,8 @@ int alt_grab = 0;unsigned int nb_prom_envs =0 ;const char *prom_envs[MAX_PROM_ENVS ];#endif -static int nb_drives_opt; -static struct drive_opt { -const char *file; -char opt[1024 ]; -} drives_opt[MAX_DRIVES ]; +int nb_drives_opt; +struct drive_opt drives_opt[MAX_DRIVES ];static CPUState *cur_cpu;static CPUState *next_cpu;
Signature · 1 line
1.6.0.6
PATCH 7/9 Support pci=... in option argument of -drive if=virtio
In reply to Markus ArmbrusterFrom: Markus Armbruster <[email protected]>
--- hw/pc.c | 3 ++- hw/ppc440_bamboo.c | 3 ++- hw/virtio-blk.c | 2 +- hw/virtio-blk.h | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-)
hw/pc.c +2 -1
@@ -1091,7 +1091,8 @@ vga_bios_error:int unit_id =0 ;while ((index =drive_get_index (IF_VIRTIO ,0 , unit_id)) !=-1 ) { -virtio_blk_init (pci_bus, drives_table[index].bdrv); +virtio_blk_init (drives_table[index].bdrv, + drives_opt[drives_table[index].drive_opt_idx].opt); unit_id++; } }
hw/ppc440_bamboo.c +2 -1
@@ -112,7 +112,8 @@ static void bamboo_init(ram_addr_t ram_size, int vga_ram_size,/* Add virtio block devices. */ while ((i =drive_get_index (IF_VIRTIO ,0 , unit_id)) !=-1 ) { -virtio_blk_init (pcibus, drives_table[i].bdrv); +virtio_blk_init (drives_table[i].bdrv, + drives_opt[drives_table[i].drive_opt_idx].opt); unit_id++; }
hw/virtio-blk.c +1 -1
@@ -218,7 +218,7 @@ static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id)return 0 ; } -void *virtio_blk_init (PCIBus *bus,BlockDriverState *bs) +void *virtio_blk_init (BlockDriverState *bs,const char *opts) {VirtIOBlock *s;int cylinders, heads, secs;
hw/virtio-blk.h +1 -1
@@ -70,6 +70,6 @@ struct virtio_blk_inhdr unsigned char status; }; -void *virtio_blk_init (PCIBus *bus,BlockDriverState *bs); +void *virtio_blk_init (BlockDriverState *bs,const char *opts);#endif
Signature · 1 line
1.6.0.6
PATCH 8/9 New option -audio as a more flexible alternative to -soundhw
In reply to Markus ArmbrusterFrom: Markus Armbruster <[email protected]>
This is in preparation of pci=... support for audio devices. -soundhw doesn't support the common name=value,... syntax.
--- sysemu.h | 1 + vl.c | 94 ++++++++++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 69 insertions(+), 26 deletions(-)
sysemu.h +1 -0
@@ -199,6 +199,7 @@ void pstrcpy_targphys(target_phys_addr_t dest, int buf_size,struct soundhw {const char *name;const char *descr; +const char *opts;int enabled;int isa;union {
vl.c +68 -26
194 lines not on this page · raw message
Signature · 1 line
1.6.0.6
Re: [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw
Quoted 8 lines · Markus Armbruster
From: Markus Armbruster <[email protected]>
This is in preparation of pci=... support for audio devices. -soundhw doesn't support the common name=value,... syntax.
---sysemu.h| 1 +vl.c| 94 ++++++++++++++++++++++++++++++++++++++++++++-----------------2 files changed, 69 insertions(+), 26 deletions(-)
This as, i guess, the rest of the patches is tab damaged. The documentation wasn't updated either.
[..snip..]
Signature · 1 line
mailto:[email protected]
Re: [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw
Quoted 11 lines · malc
Quoted 8 lines · Markus Armbruster
From: Markus Armbruster <[email protected]>
This is in preparation of pci=... support for audio devices. -soundhw doesn't support the common name=value,... syntax.
---sysemu.h| 1 +vl.c| 94 ++++++++++++++++++++++++++++++++++++++++++++-----------------2 files changed, 69 insertions(+), 26 deletions(-)
Quoted 4 lines
This as, i guess, the rest of the patches is tab damaged. The documentation wasn't updated either.
[..snip..]
It's just a sketch. How would you like your tabs?
Re: [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw
Quoted 12 lines · Markus Armbruster
Quoted 10 lines · malc
Quoted 8 lines · Markus Armbruster
From: Markus Armbruster <[email protected]>
This is in preparation of pci=... support for audio devices. -soundhw doesn't support the common name=value,... syntax.
---sysemu.h| 1 +vl.c| 94 ++++++++++++++++++++++++++++++++++++++++++++-----------------2 files changed, 69 insertions(+), 26 deletions(-)
Quoted 6 lines
Quoted 4 lines
This as, i guess, the rest of the patches is tab damaged. The documentation wasn't updated either.
[..snip..]
It's just a sketch. How would you like your tabs?
Probably four spaces, just like in the surrounding code (as almost everywhere in qemu).
Kevin
Re: [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw
Quoted 16 lines · Kevin Wolf
Quoted 15 lines · Markus Armbruster
Quoted 13 lines · malc
Quoted 8 lines · Markus Armbruster
From: Markus Armbruster <[email protected]>
This is in preparation of pci=... support for audio devices. -soundhw doesn't support the common name=value,... syntax.
---sysemu.h| 1 +vl.c| 94 ++++++++++++++++++++++++++++++++++++++++++++-----------------2 files changed, 69 insertions(+), 26 deletions(-)This as, i guess, the rest of the patches is tab damaged. The documentation wasn't updated either.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
[..snip..]
It's just a sketch. How would you like your tabs?
Probably four spaces, just like in the surrounding code (as almost everywhere in qemu).
Kevin
Can't see where I got that wrong.
Any preference on use of the tab character?
Re: [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw
Quoted 20 lines · Markus Armbruster
Quoted 18 lines · Kevin Wolf
Quoted 17 lines · Markus Armbruster
Quoted 10 lines · malc
Quoted 8 lines · Markus Armbruster
From: Markus Armbruster <[email protected]>
This is in preparation of pci=... support for audio devices. -soundhw doesn't support the common name=value,... syntax.
---sysemu.h| 1 +vl.c| 94 ++++++++++++++++++++++++++++++++++++++++++++-----------------2 files changed, 69 insertions(+), 26 deletions(-)Quoted 4 lines
This as, i guess, the rest of the patches is tab damaged. The documentation wasn't updated either.
[..snip..]
It's just a sketch. How would you like your tabs?
Quoted 8 lines
Quoted 4 lines
Probably four spaces, just like in the surrounding code (as almost everywhere in qemu).
Kevin
Can't see where I got that wrong.
Any preference on use of the tab character?
Most of the qemu code only uses spaces, no real tabs.
Kevin
Re: [Qemu-devel] [PATCH 8/9] New option -audio as a more flexible alternative to -soundhw
Quoted 26 lines · Kevin Wolf
Quoted 25 lines · Markus Armbruster
Quoted 22 lines · Kevin Wolf
Quoted 12 lines · Markus Armbruster
Quoted 10 lines · malc
Quoted 8 lines · Markus Armbruster
From: Markus Armbruster <[email protected]>
This is in preparation of pci=... support for audio devices. -soundhw doesn't support the common name=value,... syntax.
---sysemu.h| 1 +vl.c| 94 ++++++++++++++++++++++++++++++++++++++++++++-----------------2 files changed, 69 insertions(+), 26 deletions(-)Quoted 5 lines
Quoted 4 lines
This as, i guess, the rest of the patches is tab damaged. The documentation wasn't updated either.
[..snip..]
It's just a sketch. How would you like your tabs?
Probably four spaces, just like in the surrounding code (as almost everywhere in qemu).
Kevin
Quoted 7 lines
Quoted 3 lines
Can't see where I got that wrong.
Any preference on use of the tab character?
Most of the qemu code only uses spaces, no real tabs.
Kevin
I didn't bother to avoid tabs, because I found them in existing code. But I can certainly avoid them. Thanks!
PATCH 9/9 Support pci=... in option argument of -audio
In reply to Markus ArmbrusterFrom: Markus Armbruster <[email protected]>
--- hw/ac97.c | 11 +++-------- hw/audiodev.h | 4 ++-- hw/es1370.c | 11 +++-------- hw/mips_malta.c | 6 +++--- hw/pc.c | 11 ++++------- sysemu.h | 2 +- 6 files changed, 16 insertions(+), 29 deletions(-)
hw/ac97.c +3 -8
@@ -1308,25 +1308,20 @@ static void ac97_on_reset (void *opaque)mixer_reset (s); } -int ac97_init (PCIBus *bus,AudioState *audio) +int ac97_init (AudioState *audio,const char *opts) {PCIAC97LinkState *d;AC97LinkState *s;uint8_t *c; -if (!bus) { -AUD_log ("ac97" ,"No PCI bus\n" ); -return -1 ; - } -if (!audio) {AUD_log ("ac97" ,"No audio state\n" );return -1 ; } - d = (PCIAC97LinkState *)pci_register_device (bus,"AC97" , + d = (PCIAC97LinkState *)pci_register_device_2 ("AC97" , opts,sizeof (PCIAC97LinkState), --1 ,NULL ,NULL ); +NULL ,NULL );if (!d) {AUD_log ("ac97" ,"Failed to register PCI device\n" );
hw/audiodev.h +2 -2
@@ -1,5 +1,5 @@/* es1370.c */ -int es1370_init (PCIBus *bus,AudioState *s); +int es1370_init (AudioState *s,const char *opts);/* sb16.c */ int SB16_init (AudioState *s,qemu_irq *pic);
@@ -11,7 +11,7 @@ int Adlib_init (AudioState *s, qemu_irq *pic);int GUS_init (AudioState *s,qemu_irq *pic);/* ac97.c */ -int ac97_init (PCIBus *buf,AudioState *s); +int ac97_init (AudioState *s,const char *opts);/* cs4231a.c */ int cs4231a_init (AudioState *s,qemu_irq *pic);
hw/es1370.c +3 -8
@@ -1005,25 +1005,20 @@ static void es1370_on_reset (void *opaque)es1370_reset (s); } -int es1370_init (PCIBus *bus,AudioState *audio) +int es1370_init (AudioState *audio,const char *opts) {PCIES1370State *d;ES1370State *s;uint8_t *c; -if (!bus) { -dolog ("No PCI bus\n" ); -return -1 ; - } -if (!audio) {dolog ("No audio state\n" );return -1 ; } - d = (PCIES1370State *)pci_register_device (bus,"ES1370" , + d = (PCIES1370State *)pci_register_device_2 ("ES1370" , opts,sizeof (PCIES1370State), --1 ,NULL ,NULL ); +NULL ,NULL );if (!d) {AUD_log (NULL ,"Failed to register PCI device for ES1370\n" );
hw/mips_malta.c +3 -3
@@ -459,7 +459,7 @@ static MaltaFPGAState *malta_fpga_init(target_phys_addr_t base, qemu_irq uart_ir/* Audio support */ #ifdef HAS_AUDIO -static void audio_init (PCIBus *pci_bus) +static void audio_init (void ) {struct soundhw *c;int audio_enabled =0 ;
@@ -475,7 +475,7 @@ static void audio_init (PCIBus *pci_bus)if (s) {for (c = soundhw; c->name; ++c) {if (c->enabled) - c->init.init_pci (pci_bus, s); + c->init.init_pci (s, c->opts); } } }
@@ -927,7 +927,7 @@ void mips_malta_init (ram_addr_t ram_size, int vga_ram_size,/* Sound card */ #ifdef HAS_AUDIO -audio_init (pci_bus); +audio_init ();#endif /* Network card */
hw/pc.c +4 -7
@@ -709,7 +709,7 @@ static int parallel_io[MAX_PARALLEL_PORTS] = { 0x378, 0x278, 0x3bc };static int parallel_irq[MAX_PARALLEL_PORTS ] = {7 ,7 ,7 };#ifdef HAS_AUDIO -static void audio_init (PCIBus *pci_bus,qemu_irq *pic) +static void audio_init (qemu_irq *pic) {struct soundhw *c;int audio_enabled =0 ;
@@ -727,11 +727,8 @@ static void audio_init (PCIBus *pci_bus, qemu_irq *pic)if (c->enabled) {if (c->isa) { c->init.init_isa (s, pic); - } -else { -if (pci_bus) { - c->init.init_pci (pci_bus, s); - } + }else { + c->init.init_pci (s, c->opts); } } }
@@ -1034,7 +1031,7 @@ vga_bios_error:i8042_init (i8259[1 ], i8259[12 ],0x60 );DMA_init (0 );#ifdef HAS_AUDIO -audio_init (pci_enabled ? pci_bus :NULL , i8259); +audio_init (i8259);#endif for (i =0 ; i <MAX_FD ; i++) {
sysemu.h +1 -1
@@ -204,7 +204,7 @@ struct soundhw {int isa;union {int (*init_isa) (AudioState *s,qemu_irq *pic); -int (*init_pci) (PCIBus *bus,AudioState *s); +int (*init_pci) (AudioState *s,const char *opts); } init; };
Signature · 1 line
1.6.0.6
Quoted 11 lines · Markus Armbruster
This patch series makes PCI device addresses configurable for a number of devices. For now, I just covered the ones I consider important and/or where the change is somewhat invasive.
Why is a configurable PCI device address useful? Currently, QEMU assigns a few device addresses statically, and the rest dynamically on a first come, first serve basis[*]. If you add or remove a device, all devices registering later change address. I'm told a certain operating system that can't be named in polite company can get rather upset about that.
Quoted 4 lines
Making the device address configurable looks like the simplest solution to this problem. Only users who really mind changing addresses have to deal with the new configuration parameter.
I think we're starting to get to the tipping point where we really just need to introduce a machine config file.
Paul, you mentioned you were working on something before? Care to update us on the status?
I know there was a fair bit of support before for a FDT based machine config.
Regards,
Anthony Liguori
Quoted 69 lines
I started with Izik's proposal to "allow setting static slot values for pci devices from the command line", see
http://lists.gnu.org/archive/html/qemu-devel/2008-01/msg00601.html http://lists.gnu.org/archive/html/qemu-devel/2007-11/msg00620.htmlbut ended up doing it quite differently.
I'm just soliciting comments. I do *not* ask for a commit of anything right now.
The patch series consists of these parts:
[1/9] PCI device registration helpers
[2/9] Clean up handling of name=value,... part of -vga option argument [3/9] Support pci=... in option argument of -vga
[4/9] Convertvirtio_init_pci()topci_register_device_2()[5/9] Support pci=... in option argument of -net nic
[6/9] Make drives_opt[] accessible from device initialization [7/9] Support pci=... in option argument of -drive if=virtio [8/9] New option -audio as a more flexible alternative to -soundhw [9/9] Support pci=... in option argument of -audioOverall diffstat:
hw/ac97.c | 11 +--- hw/audiodev.h | 4 +- hw/cirrus_vga.c | 6 +- hw/e1000.c | 6 +- hw/eepro100.c | 19 ++++---- hw/es1370.c | 11 +--- hw/mips_malta.c | 17 +++---- hw/ne2000.c | 7 +-- hw/pc.c | 23 ++++------ hw/pc.h | 11 +--- hw/pci.c | 109 ++++++++++++++++++++++++++++++++++++++++++++-- hw/pci.h | 25 ++++++---- hw/pcnet.c | 6 +- hw/ppc440_bamboo.c | 5 +- hw/ppc_chrp.c | 4 +- hw/ppc_oldworld.c | 4 +- hw/ppc_prep.c | 4 +- hw/r2d.c | 8 ++-- hw/realview.c | 2 +- hw/rtl8139.c | 7 +-- hw/sun4u.c | 4 +- hw/versatilepb.c | 2 +- hw/vga.c | 40 ++++++++-------- hw/virtio-balloon.c | 2 +- hw/virtio-blk.c | 4 +- hw/virtio-blk.h | 2 +- hw/virtio-console.c | 2 +- hw/virtio-net.c | 5 +- hw/virtio-net.h | 2 +- hw/virtio.c | 5 +- hw/virtio.h | 2 +- hw/vmware_vga.c | 7 ++- net.c | 1 + net.h | 1 + sysemu.h | 13 +++++- vl.c | 120 ++++++++++++++++++++++++++++++++------------------- 36 files changed, 315 insertions(+), 186 deletions(-)[*] To be precise: it assigns the dev.func part dynamically. The domain:bus: part is still statically assigned.
Quoted 12 lines · Anthony Liguori
Quoted 11 lines · Markus Armbruster
This patch series makes PCI device addresses configurable for a number of devices. For now, I just covered the ones I consider important and/or where the change is somewhat invasive.
Why is a configurable PCI device address useful? Currently, QEMU assigns a few device addresses statically, and the rest dynamically on a first come, first serve basis[*]. If you add or remove a device, all devices registering later change address. I'm told a certain operating system that can't be named in polite company can get rather upset about that.
Quoted 7 lines
Quoted 4 lines
Making the device address configurable looks like the simplest solution to this problem. Only users who really mind changing addresses have to deal with the new configuration parameter.
I think we're starting to get to the tipping point where we really just need to introduce a machine config file.
Makes sense to me. But considering the idea has been mulled around for so long (half a year?) without obvious progress (obvious to ignorant me!), I chose to scratch my itch right away. Any chance I can get it scratched now, or do I have to wait for the machine description file feature?
Quoted 2 lines
Paul, you mentioned you were working on something before? Care to update us on the status?
Yes, please!
Quoted 6 lines
I know there was a fair bit of support before for a FDT based machine config.
Regards,
Anthony Liguori
Quoted 12 lines · Anthony Liguori
Quoted 11 lines · Markus Armbruster
This patch series makes PCI device addresses configurable for a number of devices. For now, I just covered the ones I consider important and/or where the change is somewhat invasive.
Why is a configurable PCI device address useful? Currently, QEMU assigns a few device addresses statically, and the rest dynamically on a first come, first serve basis[*]. If you add or remove a device, all devices registering later change address. I'm told a certain operating system that can't be named in polite company can get rather upset about that.
Quoted 7 lines
Quoted 4 lines
Making the device address configurable looks like the simplest solution to this problem. Only users who really mind changing addresses have to deal with the new configuration parameter.
I think we're starting to get to the tipping point where we really just need to introduce a machine config file.
I think we passed that point a long time ago :-) If someone were to make use of every single QEMU command line arg, with many disks & nics we're probably already hitting the ARGV size limit.
Daniel
Signature · 4 lines
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
Quoted 8 lines
I think we're starting to get to the tipping point where we really just need to introduce a machine config file.
Paul, you mentioned you were working on something before? Care to update us on the status?
I know there was a fair bit of support before for a FDT based machine config.
I have a FDT based machine descriptions working locally.
Currently it's only capable of generating a small subset ARM embedded boards. There are a few issues that need to be resolved before it can replace most of the current qemu machines:
- How to handle "plug-n-play" busses like PCI. The FDT provided to the kernel generally just describes the host bridge, and the kernel/bios figures everything else out using the normal PCI config mechanisms.
- How it will interact with commandline options like -nic that modify which hardware is present. One possibility is to remove these options (remove -net nic, but leave -net tap, etc.). If users want different numbers/types of NICs they should use a different machine config.
- How to handle GPIO pins, and other interconnects like I2S, SSI and I2C. I guess this is mainly coming up with suitable FDT representations.
I have not implemented a user level config file. My work effectively just replaces integratorcp_init and friends.
Paul
Quoted 12 lines · Paul Brook
Quoted 9 lines
I think we're starting to get to the tipping point where we really just need to introduce a machine config file.
Paul, you mentioned you were working on something before? Care to update us on the status?
I know there was a fair bit of support before for a FDT based machine config.
I have a FDT based machine descriptions working locally.
Can you post what you have?
Quoted 11 lines
Currently it's only capable of generating a small subset ARM embedded boards. There are a few issues that need to be resolved before it can replace most of the current qemu machines:
- How to handle "plug-n-play" busses like PCI. The FDT provided to the kernel
generally just describes the host bridge, and the kernel/bios figures everything else out using the normal PCI config mechanisms.
- How it will interact with commandline options like -nic that modify which
hardware is present. One possibility is to remove these options (remove -net nic, but leave -net tap, etc.). If users want different numbers/types of NICs they should use a different machine config.
- How to handle GPIO pins, and other interconnects like I2S, SSI and I2C. I
guess this is mainly coming up with suitable FDT representations.I have not implemented a user level config file. My work effectively just replaces
integratorcp_initand friends.
A user level config file can come later.
Regards,
Anthony Liguori
Quoted 2 lines
Paul
Quoted 7 lines · Anthony Liguori
Quoted 6 lines · Paul Brook
Quoted 6 lines
I think we're starting to get to the tipping point where we really just need to introduce a machine config file.
Paul, you mentioned you were working on something before? Care to update us on the status?
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
I know there was a fair bit of support before for a FDT based machine config.
I have a FDT based machine descriptions working locally.
Can you post what you have?
Yes, please!