[Qemu-devel] [PATCH] wdt_i6300esb: register a reset function
The device shall set its default hardware state after each reset. This includes that the timer is stopped which is especially important if the guest does a reboot independantly of a watchdog bite. I moved the initialization of the state variables completely from the init to the reset function which is called right after init during the first boot and afterwards during each reboot. Signed-off-by: Bernhard Kohl bernhard.k...@nsn.com --- hw/wdt_i6300esb.c | 39 +-- 1 files changed, 21 insertions(+), 18 deletions(-) diff --git a/hw/wdt_i6300esb.c b/hw/wdt_i6300esb.c index 46e1df8..2408710 100644 --- a/hw/wdt_i6300esb.c +++ b/hw/wdt_i6300esb.c @@ -140,14 +140,26 @@ static void i6300esb_disable_timer(I6300State *d) qemu_del_timer(d-timer); } -static void i6300esb_reset(I6300State *d) +static void i6300esb_reset(DeviceState *dev) { -/* XXX We should probably reset other parts of the state here, - * but we should also reset our state on general machine reset - * too. For now just disable the timer so it doesn't fire - * again after the reboot. - */ +PCIDevice *pdev = DO_UPCAST(PCIDevice, qdev, dev); +I6300State *d = DO_UPCAST(I6300State, dev, pdev); + +i6300esb_debug(I6300State = %p\n, d); + i6300esb_disable_timer(d); + +d-reboot_enabled = 1; +d-clock_scale = CLOCK_SCALE_1KHZ; +d-int_type = INT_TYPE_IRQ; +d-free_run = 0; +d-locked = 0; +d-enabled = 0; +d-timer1_preload = 0xf; +d-timer2_preload = 0xf; +d-stage = 1; +d-unlock_state = 0; +d-previous_reboot_flag = 0; } /* This function is called when the watchdog expires. Note that @@ -181,7 +193,6 @@ 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); } /* In free running mode we start stage 1 again. */ @@ -394,18 +405,9 @@ static int i6300esb_init(PCIDevice *dev) I6300State *d = DO_UPCAST(I6300State, dev, dev); uint8_t *pci_conf; -d-reboot_enabled = 1; -d-clock_scale = CLOCK_SCALE_1KHZ; -d-int_type = INT_TYPE_IRQ; -d-free_run = 0; -d-locked = 0; -d-enabled = 0; +i6300esb_debug(I6300State = %p\n, d); + d-timer = qemu_new_timer(vm_clock, i6300esb_timer_expired, d); -d-timer1_preload = 0xf; -d-timer2_preload = 0xf; -d-stage = 1; -d-unlock_state = 0; -d-previous_reboot_flag = 0; pci_conf = d-dev.config; pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL); @@ -427,6 +429,7 @@ static PCIDeviceInfo i6300esb_info = { .qdev.name= i6300esb, .qdev.size= sizeof(I6300State), .qdev.vmsd= vmstate_i6300esb, +.qdev.reset = i6300esb_reset, .config_read = i6300esb_config_read, .config_write = i6300esb_config_write, .init = i6300esb_init, -- 1.7.2.3
Re: [Qemu-devel] State of EHCI emulation for QEMU
On 12/08/10 01:32, Jan Kiszka wrote: Am 08.12.2010 09:26, Gerd Hoffmann wrote: Hi, It appears that the import of the ehci code to spice has completely lost the development history and code contributions - from the original version by Mark Burkley through the work I've done on it. Would you mind pulling in the patch history instead of just the final code? I've first tried to rebase the ehci branch to latest master exactly to keep the history. Was quite messy with lots of conflicts though, so I gave up. For review upstream merge having the whole history isn't that helpful anyway. Where was the messiness given that most of the changes are to a brand new file? The biggest change after that is to usb-linux to handle large requests. David I'm was regularly merging master into ehci, and that worked quite well. For the development phase, it might be nice to keep the history if possible. But I agree that we need a clean series once upstream submission is in sight. Jan
[Qemu-devel] [PATCH] blockdev: check dinfo ptr before using
If a user decides to punish a guest by revoking its block device via drive_del, and subsequently also attempts to remove the pci device backing it, and the device is using blockdev_auto_del() then we get a segfault when we attempt to access dinfo-auto_del.[1] The fix is to check if drive_get_by_blockdev() actually returns a valid dinfo pointer or not. 1. (qemu) pci_add auto storage file=images/test01.raw,if=virtio,id=block1,snapshot=on (qemu) drive_del block1 (qemu) pci_del 5 *segfault* Signed-off-by: Ryan Harper ry...@us.ibm.com -- Ryan Harper Software Engineer; Linux Technology Center IBM Corp., Austin, Tx ry...@us.ibm.com diff --git a/blockdev.c b/blockdev.c index f6ac439..3b3b82d 100644 --- a/blockdev.c +++ b/blockdev.c @@ -30,14 +30,16 @@ void blockdev_mark_auto_del(BlockDriverState *bs) { DriveInfo *dinfo = drive_get_by_blockdev(bs); -dinfo-auto_del = 1; +if (dinfo) { +dinfo-auto_del = 1; +} } void blockdev_auto_del(BlockDriverState *bs) { DriveInfo *dinfo = drive_get_by_blockdev(bs); -if (dinfo-auto_del) { +if (dinfo dinfo-auto_del) { drive_uninit(dinfo); } }
[Qemu-devel] IRC channel movement - FreeNode to OFTC
Hi, I'd like to move IRC channels from FreeNode to OFTC, so please join #qemu on OFTC starting now. Regards, Anthony Liguori
Re: [Qemu-devel] [PATCH v8 7/7] virtio-console: Enable port throttling when chardev is slow to consume data
But that's entirely in guest memory, so it's limited to the amount of RAM that has been allocated to the guest. Exactly. The guest can cause ram_size * nr_ports of additional host memory to be allocated. Not acceptable. OK -- so this is how it adds up: - guest vq - virtio-serial-bus converts iov to buf This is an unbelievably lame piece of code. I doubt it's 'unbelievably lame' just because of the copy. Care to expand? Specifically that we are allocating a host buffer of guest-specified size to hold that copy. There's absolutely no reason to copy the data into a linear buffer. You should just be iterating over the elements of the sglist. OK, but that can be done in a separate patch series. I suspect you'll actually find it easier to fix that first. Otherwise you're going end up having to rewrite your own code. - qemu-char stores the buf in case it wasn't able to send but then, since it's all async, we have: - virtio-serial-bus frees the buf - guest deletes the buf and removes it from the vq So what's left is only the data in qemu-char's buf. Now this can be (buf_size - 1) * nr_ports in the worst case. Add at least another buf_size because you have to allocate the qemu-char buffer before you free the virtio-serial buffer. We can expect that buf_size ~= guest ram size [1], so for practical purposes it may as well be unbounded. Now this only happens when the host chardev is slow or isn't being read from. So it's not really a guest causing a host DoS, but a guest causing itself some harm. No. It causes qemu to allocate and use an arbitrarily large amount of additional ram on the host. This is likely to effect the whole host machine, not just the problematic guest. You can hope the OOM killer happens to pick the right guest, but I wouldn't bet on it. You're right that the allocations happen one after the other, and the freeing happens later, so there is a time when 2 or 3 times the buf_size is needed. However, once qemu_chr_write() returns, there could be just one copy lying around, things are freed elsewhere. One copy (multiplied by the number of ports) is more than enough to cause serious problems. but then that depends on qemu getting async support - separating out the qemu_chr_write() into a separate thread and allowing vcpu and chr io operations to be run simultaneously. You don't need any special async char API or threads. Normal unix write semantics (i.e. short writes and EAGAIN) plus the unblock hook are sufficient. As mentioned above, the virtio-serial code should be iterating over the sglist. If the host won't accept all the data immediately then just remember how much has been sent, and resume iteration when the unblock hook is called. Yes I've been thinking about this as well. But the problem is some kernel versions spin in the guest code till the buffer is placed back in the vq (signalling it's done using it). This is a problem for the virtio-console (hvc) that does writes with spinlocks held, so allocating new buffers, etc., isn't really -- possible easily. That's a guest bug, plain and simple. I'm pretty sure such guests will still loose after your patch. All you're doing is delaying the inevitable slightly. i.e. if a guest happens to submit another block before the first has been flushed then it will spin in exactly the same way. Paul
[Qemu-devel] Re: [PATCH] blockdev: check dinfo ptr before using
On Wed, 8 Dec 2010 10:05:00 -0600 Ryan Harper ry...@us.ibm.com wrote: If a user decides to punish a guest by revoking its block device via drive_del, and subsequently also attempts to remove the pci device backing it, and the device is using blockdev_auto_del() then we get a segfault when we attempt to access dinfo-auto_del.[1] The fix is to check if drive_get_by_blockdev() actually returns a valid dinfo pointer or not. 1. (qemu) pci_add auto storage file=images/test01.raw,if=virtio,id=block1,snapshot=on (qemu) drive_del block1 (qemu) pci_del 5 *segfault* Signed-off-by: Ryan Harper ry...@us.ibm.com Fixes my test case: Tested-by: Luiz Capitulino lcapitul...@redhat.com
Re: [Qemu-devel] Re: [RFC][PATCH v5 09/21] virtagent: add va.getdmesg RPC
On 12/07/10 18:32, Michael Roth wrote: On 12/07/2010 08:37 AM, Jes Sorensen wrote: On 12/03/10 19:03, Michael Roth wrote: +static xmlrpc_value *va_getdmesg(xmlrpc_env *env, + xmlrpc_value *param, + void *user_data) +{ +char *dmesg_buf = NULL, cmd[256]; +int ret; +xmlrpc_value *result = NULL; +FILE *pipe; + +SLOG(va_getdmesg()); + +dmesg_buf = qemu_mallocz(VA_DMESG_LEN + 2048); +sprintf(cmd, dmesg -s %d, VA_DMESG_LEN); What happens if the guest's dmesg buffer is larger than your hardcoded value? It'll end up getting truncated by the fread() later: ret = fread(dmesg_buf, sizeof(char), VA_DMESG_LEN, pipe); That's where the dmesg -s VA_DMESG_LEN comes into play, it should size things such that we can buffer up till the end of the dmesg output. This param is kind of quirky though, size doesn't seem to have an affect for anything below 4KB, but if we stick with VA_DMESG_LEN = 4KB this should cover us, unless it's a distro-specific. But it should blow anything up, at least. I am wary of these hard coded constants. Isn't there a way to set the kernel's dmesg buffer size, or is that only a compile time option? Cheers, Jes
[Qemu-devel] [PATCH] Fix segfault with ram_size 4095M without kvm
Currently, x86_64-softmmu qemu segfaults when trying to use 4095M memsize. This patch adds a simple check and error message (much like the 2047 limit on 32-bit hosts) on ram_size in the control path after we determine we're not using kvm Upstream qemu-kvm is affected if using the -no-kvm option; this patch address the segfault there as well. Signed-off-by: Ryan Harper ry...@us.ibm.com Signed-off-by: Aurelien Jarno aurel...@aurel32.net --- NOTE: this patch was applied in the v0.12.x branch, but it seems it got lost for master vl.c |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/vl.c b/vl.c index 2dbb6db..bb9c21c 100644 --- a/vl.c +++ b/vl.c @@ -5792,6 +5792,12 @@ int main(int argc, char **argv, char **envp) fprintf(stderr, failed to initialize KVM\n); exit(1); } +} else { +/* without kvm enabled, we can only support 4095 MB RAM */ +if (ram_size (4095UL 20)) { +fprintf(stderr, qemu: without kvm support at most 4095 MB RAM can be simulated\n); +exit(1); +} } if (qemu_init_main_loop()) { -- 1.7.3.3.402.ga48aa
[Qemu-devel] Re: seabios: acpi: add _RMV control method for PCI devices
On Wed, Dec 08, 2010 at 07:34:42PM +0200, Gleb Natapov wrote: On Wed, Dec 08, 2010 at 03:08:59PM -0200, Marcelo Tosatti wrote: Use _RMV method to indicate whether device can be removed. But Windows still shows device as removable in the gui and allows to remove it, correct? No. From Designing Hardware for Surprise Removal under Windows XP document: An ACPI BIOS can override the Removable capability by using the _RMV method ... +#define gen_pci_device(name, nr)\ +Device(SL##name) { \ +Name (_ADR, nr##) \ +Method (_RMV) { \ +If (And(\_SB.PCI0.PCRM, ShiftLeft(1, nr))) {\ +Return (0x1)\ +} \ +Return (0x0)\ +} \ +Name (_SUN, name) \ +} Why not add this to hotplug_slot() macro? Because its ignored if declared in the device object thats a child of SB.PCI0 (hotplug_slot).
[Qemu-devel] Re: [PATCH v2 1/2] Do not register kvmclock savevm section if kvmclock is disabled.
On Tue, Dec 07, 2010 at 03:12:36PM -0200, Glauber Costa wrote: On Mon, 2010-12-06 at 19:04 -0200, Marcelo Tosatti wrote: On Mon, Dec 06, 2010 at 09:03:46AM -0500, Glauber Costa wrote: Usually nobody usually thinks about that scenario (me included and specially), but kvmclock can be actually disabled in the host. It happens in two scenarios: 1. host too old. 2. we passed -kvmclock to our -cpu parameter. In both cases, we should not register kvmclock savevm section. This patch achives that by registering this section only if kvmclock is actually currently enabled in cpuid. The only caveat is that we have to register the savevm section a little bit later, since we won't know the final kvmclock state before cpuid gets parsed. What is the problem of registering the section? Restoring the value if the host does not support it returns an error? Can't you ignore the error if kvmclock is not reported in cpuid, in the restore handler? We can change the restore handler, but not the restore handler of binaries that are already out there. The motivation here is precisely to address migration to hosts without kvmclock, so it's better to have a way to disable, than to count on the fact that the other side will be able to ignore it. OK. Can't you register conditionally on kvmclock cpuid bit at the end of kvm_arch_init_vcpu, in target-i386/kvm.c?
[Qemu-devel] [Bug 685096] Re: USB Passthrough not working for Windows 7 guest
I suffer from the same issue using QEMU 1.1. I tried 5 different USB thumbdrives and none of them worked. Interesting was that a USB 1.1 mouse was working though. -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/685096 Title: USB Passthrough not working for Windows 7 guest Status in QEMU: New Bug description: USB Passthrough from host to guest is not working for a 32-bit Windows 7 guest, while it works perfectly for a 32-bit Windows XP guest. The device appears in the device manager of Windows 7, but with Error code 10: device cannot start. I have tried this with numerous USB thumbdrives and a USB wireless NIC, all with the same result. The device name and functionality is recognized, so at least some USB negotiation is taking place. I am trying this with the latest git-pull of QEMU-KVM. The command line to launch qemu-kvm for win7 is: sudo /home/user/local_install/bin/qemu-system-x86_64 -cpu core2duo -m 1024 -smp 2 -vga std -hda ./disk_images/win7.qcow -vnc :1 -boot c -usb -usbdevice tablet -usbdevice host:0781:5150 The command line to launch qemu-kvm for winxp is: sudo /home/user/local_install/bin/qemu-system-x86_64 -cpu core2duo -m 1024 -smp 2 -usb -vga std -hda ./winxpsp3.qcow -vnc :0 -boot c -usbdevice tablet -usbdevice host:0781:5150 Any help is appreciated.
[Qemu-devel] Re: seabios: acpi: add _RMV control method for PCI devices
On Wed, Dec 08, 2010 at 04:01:18PM -0200, Marcelo Tosatti wrote: On Wed, Dec 08, 2010 at 07:34:42PM +0200, Gleb Natapov wrote: On Wed, Dec 08, 2010 at 03:08:59PM -0200, Marcelo Tosatti wrote: Use _RMV method to indicate whether device can be removed. But Windows still shows device as removable in the gui and allows to remove it, correct? No. From Designing Hardware for Surprise Removal under Windows XP document: An ACPI BIOS can override the Removable capability by using the _RMV method ... Cool. I wonder how it co-exists with _EJ0 method for the same device. +#define gen_pci_device(name, nr)\ +Device(SL##name) { \ +Name (_ADR, nr##) \ +Method (_RMV) { \ +If (And(\_SB.PCI0.PCRM, ShiftLeft(1, nr))) {\ +Return (0x1)\ +} \ +Return (0x0)\ +} \ +Name (_SUN, name) \ +} Why not add this to hotplug_slot() macro? Because its ignored if declared in the device object thats a child of SB.PCI0 (hotplug_slot). Any idea why? -- Gleb.
[Qemu-devel] Re: [PATCH] Fix segfault with ram_size 4095M without kvm
On 12/08/2010 12:01 PM, Luiz Capitulino wrote: Currently, x86_64-softmmu qemu segfaults when trying to use 4095M memsize. This patch adds a simple check and error message (much like the 2047 limit on 32-bit hosts) on ram_size in the control path after we determine we're not using kvm Upstream qemu-kvm is affected if using the -no-kvm option; this patch address the segfault there as well. Signed-off-by: Ryan Harperry...@us.ibm.com Signed-off-by: Aurelien Jarnoaurel...@aurel32.net --- NOTE: this patch was applied in the v0.12.x branch, but it seems it got lost for master No, it was intentional. We should fix the segv, this is not a known limitation but rather a bug. Regards, Anthony Liguori vl.c |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/vl.c b/vl.c index 2dbb6db..bb9c21c 100644 --- a/vl.c +++ b/vl.c @@ -5792,6 +5792,12 @@ int main(int argc, char **argv, char **envp) fprintf(stderr, failed to initialize KVM\n); exit(1); } +} else { +/* without kvm enabled, we can only support 4095 MB RAM */ +if (ram_size (4095UL 20)) { +fprintf(stderr, qemu: without kvm support at most 4095 MB RAM can be simulated\n); +exit(1); +} } if (qemu_init_main_loop()) {
[Qemu-devel] Re: [PATCH] Fix segfault with ram_size 4095M without kvm
On Wed, 08 Dec 2010 12:23:12 -0600 Anthony Liguori aligu...@linux.vnet.ibm.com wrote: On 12/08/2010 12:01 PM, Luiz Capitulino wrote: Currently, x86_64-softmmu qemu segfaults when trying to use 4095M memsize. This patch adds a simple check and error message (much like the 2047 limit on 32-bit hosts) on ram_size in the control path after we determine we're not using kvm Upstream qemu-kvm is affected if using the -no-kvm option; this patch address the segfault there as well. Signed-off-by: Ryan Harperry...@us.ibm.com Signed-off-by: Aurelien Jarnoaurel...@aurel32.net --- NOTE: this patch was applied in the v0.12.x branch, but it seems it got lost for master No, it was intentional. We should fix the segv, this is not a known limitation but rather a bug. A TCG bug, I presume? Regards, Anthony Liguori vl.c |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/vl.c b/vl.c index 2dbb6db..bb9c21c 100644 --- a/vl.c +++ b/vl.c @@ -5792,6 +5792,12 @@ int main(int argc, char **argv, char **envp) fprintf(stderr, failed to initialize KVM\n); exit(1); } +} else { +/* without kvm enabled, we can only support 4095 MB RAM */ +if (ram_size (4095UL 20)) { +fprintf(stderr, qemu: without kvm support at most 4095 MB RAM can be simulated\n); +exit(1); +} } if (qemu_init_main_loop()) {
[Qemu-devel] Re: [PATCH] Fix segfault with ram_size 4095M without kvm
On 12/08/2010 12:27 PM, Luiz Capitulino wrote: On Wed, 08 Dec 2010 12:23:12 -0600 Anthony Liguorialigu...@linux.vnet.ibm.com wrote: On 12/08/2010 12:01 PM, Luiz Capitulino wrote: Currently, x86_64-softmmu qemu segfaults when trying to use 4095M memsize. This patch adds a simple check and error message (much like the 2047 limit on 32-bit hosts) on ram_size in the control path after we determine we're not using kvm Upstream qemu-kvm is affected if using the -no-kvm option; this patch address the segfault there as well. Signed-off-by: Ryan Harperry...@us.ibm.com Signed-off-by: Aurelien Jarnoaurel...@aurel32.net --- NOTE: this patch was applied in the v0.12.x branch, but it seems it got lost for master No, it was intentional. We should fix the segv, this is not a known limitation but rather a bug. A TCG bug, I presume? Dunno, that's why we shouldn't just paper over it. Regards, Anthony Liguori Regards, Anthony Liguori vl.c |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/vl.c b/vl.c index 2dbb6db..bb9c21c 100644 --- a/vl.c +++ b/vl.c @@ -5792,6 +5792,12 @@ int main(int argc, char **argv, char **envp) fprintf(stderr, failed to initialize KVM\n); exit(1); } +} else { +/* without kvm enabled, we can only support 4095 MB RAM */ +if (ram_size (4095UL 20)) { +fprintf(stderr, qemu: without kvm support at most 4095 MB RAM can be simulated\n); +exit(1); +} } if (qemu_init_main_loop()) {
[Qemu-devel] Re: seabios: acpi: add _RMV control method for PCI devices
On Wed, Dec 08, 2010 at 09:58:35PM +0200, Gleb Natapov wrote: On Wed, Dec 08, 2010 at 04:01:18PM -0200, Marcelo Tosatti wrote: On Wed, Dec 08, 2010 at 07:34:42PM +0200, Gleb Natapov wrote: On Wed, Dec 08, 2010 at 03:08:59PM -0200, Marcelo Tosatti wrote: Use _RMV method to indicate whether device can be removed. But Windows still shows device as removable in the gui and allows to remove it, correct? No. From Designing Hardware for Surprise Removal under Windows XP document: An ACPI BIOS can override the Removable capability by using the _RMV method ... Cool. I wonder how it co-exists with _EJ0 method for the same device. The Linux driver, at least, will use the _EJ0 method of the first device object. I guess Windows does the same. +#define gen_pci_device(name, nr)\ +Device(SL##name) { \ +Name (_ADR, nr##) \ +Method (_RMV) { \ +If (And(\_SB.PCI0.PCRM, ShiftLeft(1, nr))) {\ +Return (0x1)\ +} \ +Return (0x0)\ +} \ +Name (_SUN, name) \ +} Why not add this to hotplug_slot() macro? Because its ignored if declared in the device object thats a child of SB.PCI0 (hotplug_slot). Any idea why? -- Gleb. Because _EJ0 overrides _RMV when deciding removability, inside a device object (just checked). So the above if declared in a child of SB.PCI0... is wrong.
[Qemu-devel] Re: [PATCH 09/13] ahci: add ahci emulation
On Wed, Dec 8, 2010 at 12:13 PM, Alexander Graf ag...@suse.de wrote: +struct AHCIDevice { + IDEBus port; + int port_no; + uint32_t port_state; + uint32_t finished; + AHCIPortRegs port_regs; + struct AHCIState *hba; + uint8_t *lst; + uint8_t *res_fis; + uint8_t *cmd_fis; Are these unmapped on reset? + int cmd_fis_len; + int dma_status; + BlockDriverCompletionFunc *dma_cb; + AHCICmdHdr *cur_cmd; + NCQTransferState ncq_tfs[AHCI_MAX_CMDS]; Are the ncq_tfs[] elements cleaned up on reset (i.e. cancellation and free sglist)? +static void map_page(uint8_t **ptr, uint64_t addr, uint32_t wanted) +{ + target_phys_addr_t len = wanted; + + if (*ptr) { + cpu_physical_memory_unmap(*ptr, 1, len, len); + } + + *ptr = cpu_physical_memory_map(addr, len, 1); + if (len wanted) { + cpu_physical_memory_unmap(*ptr, 1, len, len); *ptr = NULL; +static void ncq_cb(void *opaque, int ret) +{ + NCQTransferState *ncq_tfs = (NCQTransferState *)opaque; + IDEState *ide_state; + + if (ret 0) { + /* XXX error */ + } Missing error handling. +static void process_ncq_command(AHCIState *s, int port, uint8_t *cmd_fis, + int slot, QEMUSGList *sg) +{ + NCQFrame *ncq_fis = (NCQFrame*)cmd_fis; + uint8_t tag = ncq_fis-tag 3; + NCQTransferState *ncq_tfs = s-dev[port].ncq_tfs[tag]; + + if (ncq_tfs-used) { + /* error - already in use */ + fprintf(stderr, %s: tag %d already used\n, __FUNCTION__, tag); + return; + } + + ncq_tfs-used = 1; + ncq_tfs-drive = s-dev[port]; + ncq_tfs-drive-cmd_fis = cmd_fis; + ncq_tfs-drive-cmd_fis_len = 0x20; + ncq_tfs-slot = slot; + ncq_tfs-lba = ((uint64_t)ncq_fis-lba5 40) | + ((uint64_t)ncq_fis-lba4 32) | + ((uint64_t)ncq_fis-lba3 24) | + ((uint64_t)ncq_fis-lba2 16) | + ((uint64_t)ncq_fis-lba1 8) | + (uint64_t)ncq_fis-lba0; + + /* Note: We calculate the sector count, but don't currently rely on it. + * The total size of the DMA buffer tells us the transfer size instead. */ + ncq_tfs-sector_count = ((uint16_t)ncq_fis-sector_count_high 8) | + ncq_fis-sector_count_low; + + DPRINTF(port, NCQ transfer LBA from %ld to %ld, drive max %ld\n, + ncq_tfs-lba, ncq_tfs-lba + ncq_tfs-sector_count - 2, + s-dev[port].port.ifs[0].nb_sectors - 1); + + ncq_tfs-sglist = *sg; + ncq_tfs-tag = tag; + + switch(ncq_fis-command) { + case READ_FPDMA_QUEUED: + DPRINTF(port, NCQ reading %d sectors from LBA %ld, tag %d\n, + ncq_tfs-sector_count-1, ncq_tfs-lba, ncq_tfs-tag); + ncq_tfs-is_read = 1; + + /* XXX: The specification is unclear about whether the DMA Setup + * FIS here should have the I bit set, but it suggest that it should + * not. Linux works without this interrupt, so I disabled it. + * If someone knows if it is needed, please tell me, or fix this. */ + + /* ahci_trigger_irq(s,s-dev[port],PORT_IRQ_STAT_DSS); */ + DPRINTF(port, tag %d aio read %ld\n, ncq_tfs-tag, ncq_tfs-lba); + dma_bdrv_read(ncq_tfs-drive-port.ifs[0].bs, ncq_tfs-sglist, + ncq_tfs-lba, ncq_cb, ncq_tfs); + break; + case WRITE_FPDMA_QUEUED: + DPRINTF(port, NCQ writing %d sectors to LBA %ld, tag %d\n, + ncq_tfs-sector_count-1, ncq_tfs-lba, ncq_tfs-tag); + ncq_tfs-is_read = 0; + /* ahci_trigger_irq(s,s-dev[port],PORT_IRQ_STAT_DSS); */ + DPRINTF(port, tag %d aio write %ld\n, ncq_tfs-tag, ncq_tfs-lba); + dma_bdrv_write(ncq_tfs-drive-port.ifs[0].bs, ncq_tfs-sglist, + ncq_tfs-lba, ncq_cb, ncq_tfs); + break; + default: + hw_error(ahci: tried to process non-NCQ command as NCQ\n); Guest triggerable abort. + break; + } +} + +static int handle_cmd(AHCIState *s, int port, int slot) +{ + IDEState *ide_state; + + int sglist_alloc_hint; + QEMUSGList sglist; + int atapi_packet_len = 0; + AHCIPortRegs *pr; + uint32_t opts; + uint64_t tbl_addr; + AHCICmdHdr *cmd; + uint8_t *cmd_fis; + + target_phys_addr_t cmd_len; + int i; + + if (s-dev[port].port.ifs[0].status (BUSY_STAT|DRQ_STAT)) { + /* Engine currently busy, try again later */ + DPRINTF(port, engine busy\n); + return -1; + } + + pr = s-dev[port].port_regs; + cmd = ((AHCICmdHdr *)s-dev[port].lst)[slot]; + + if (!s-dev[port].lst) { + hw_error(%s: lst not given but cmd handled, __FUNCTION__); Guest triggerable abort. + } + + opts = le32_to_cpu(cmd-opts); +
Re: [Qemu-devel] [PATCH 1/6] [RFC] Emulation of GRLIB GPTimer as defined in GRLIB IP Core User's Manual.
On Mon, Dec 06, 2010 at 10:26:02AM +0100, Fabien Chouteau wrote: Signed-off-by: Fabien Chouteau chout...@adacore.com --- hw/grlib_gptimer.c | 448 1 files changed, 448 insertions(+), 0 deletions(-) diff --git a/hw/grlib_gptimer.c b/hw/grlib_gptimer.c new file mode 100644 index 000..41edbe4 --- /dev/null +++ b/hw/grlib_gptimer.c @@ -0,0 +1,448 @@ +/* + * QEMU GRLIB GPTimer Emulator + * + * Copyright (c) 2010 AdaCore + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the Software), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include sysbus.h +#include qemu-timer.h + +#include grlib.h + +/* #define DEBUG_TIMER */ + +#ifdef DEBUG_TIMER +#define DPRINTF(fmt, ...) \ +do { printf(GPTIMER: fmt , ## __VA_ARGS__); } while (0) +#else +#define DPRINTF(fmt, ...) +#endif + +#define UNIT_REG_SIZE16 /* Size of memory mapped regs for the unit */ +#define GPTIMER_REG_SIZE 16 /* Size of memory mapped regs for a GPTimer */ + +#define GPTIMER_MAX_TIMERS 8 + +/* GPTimer Config register fields */ +#define GPTIMER_ENABLE (1 0) +#define GPTIMER_RESTART (1 1) +#define GPTIMER_LOAD(1 2) +#define GPTIMER_INT_ENABLE (1 3) +#define GPTIMER_INT_PENDING (1 4) +#define GPTIMER_CHAIN (1 5) /* Not supported */ +#define GPTIMER_DEBUG_HALT (1 6) /* Not supported */ + +/* Memory mapped register offsets */ +#define SCALER_OFFSET 0x00 +#define SCALER_RELOAD_OFFSET 0x04 +#define CONFIG_OFFSET 0x08 +#define COUNTER_OFFSET0x00 +#define COUNTER_RELOAD_OFFSET 0x04 +#define TIMER_BASE0x10 + +typedef struct GPTimer GPTimer; +typedef struct GPTimerUnit GPTimerUnit; + +struct GPTimer +{ +QEMUBH *bh; +struct ptimer_state *ptimer; + +qemu_irq irq; +int id; +GPTimerUnit *unit; + +/* registers */ +uint32_t counter; +uint32_t reload; +uint32_t config; +}; + +struct GPTimerUnit +{ +SysBusDevice busdev; + +uint32_t nr_timers; /* Number of timers available */ +uint32_t freq_hz; /* System frequency */ +uint32_t irq_line; /* Base irq line */ + +GPTimer *timers; + +/* registers */ +uint32_t scaler; +uint32_t reload; +uint32_t config; +}; + +DeviceState *grlib_gptimer_create(target_phys_addr_t base, + uint32_tnr_timers, + uint32_tfreq, + qemu_irq *cpu_irqs, + int base_irq) +{ +DeviceState *dev; +int i; + +dev = qdev_create(NULL, grlib,gptimer); +qdev_prop_set_uint32(dev, nr-timers, nr_timers); +qdev_prop_set_uint32(dev, frequency, freq); +qdev_prop_set_uint32(dev, irq-line, base_irq); + +if (qdev_init(dev)) { +return NULL; +} + +sysbus_mmio_map(sysbus_from_qdev(dev), 0, base); + +for (i = 0; i nr_timers; i++) +sysbus_connect_irq(sysbus_from_qdev(dev), i, cpu_irqs[base_irq + i]); + +return dev; +} + +static void grlib_gptimer_enable(GPTimer *timer) +{ +assert(timer != NULL); + +DPRINTF(%s id:%d\n, __func__, timer-id); + +ptimer_stop(timer-ptimer); + +if (!(timer-config GPTIMER_ENABLE)) { +/* Timer disabled */ +DPRINTF(%s id:%d Timer disabled (config 0x%x)\n, __func__, +timer-id, timer-config); +return; +} + +/* ptimer is triggered when the counter reach 0 but GPTimer is triggered at + underflow. Set count + 1 to simulate the GPTimer behavior. */ + +DPRINTF(%s id:%d set count 0x%x and run\n, +__func__, +timer-id, +timer-counter + 1); + +ptimer_set_count(timer-ptimer, timer-counter +
Re: [Qemu-devel] Re: [RFC][PATCH v5 04/21] virtagent: transport definitions and job callbacks
On 12/07/10 18:19, Michael Roth wrote: On 12/07/2010 07:44 AM, Jes Sorensen wrote: +static int va_end_of_header(char *buf, int end_pos) +{ +return !strncmp(buf+(end_pos-2), \n\r\n, 3); +} Maybe I am missing something here, but it looks like you do a strncmp to a char that is one past the end of the buffer, or? If this is intentional, please document it. buf+end_pos points to the last char we read (rather than being an offset to the current position). So it stops comparing when it reaches buf+end_pos (buf=0 + end_pos=2 implies 3 characters) For some reason this confused the hell out of me when I looked over it again as well. Alternatively I can do: static int va_end_of_header(char *buf, int end_pos) { return !strncmp(buf+(end_pos-2), \n\r\n, 3); } ... va_end_of_header(s-hdr, s-hdr_pos - 1) - static int va_end_of_header(char *buf, int cur_pos) { return !strncmp(buf+(cur_pos-3), \n\r\n, 3); } ... va_end_of_header(s-hdr, s-hdr_pos); It does seem easier to parse... I would prefer this, somewhat easier to parse. All this http parsing code leaves the question open why you do it manually, instead of relying on a library? Something like libcurl? At some point we didn't attempt to use libraries provide by xmlrpc-c (which uses libcurl for http transport) for the client and server. The problem there is that libcurl really wants and tcp socket read and write from, whereas we need to support tcp/unix sockets on the host side and isa/virtio serial ports on the guest side. Even assuming we could hook in wrappers for these other types of sockets/channels, there's also the added complexity since dropping virtproxy of multiplexing HTTP/RPCs using a single stream, whereas something like libcurl would, understandably, assume it has a dedicated stream to read/write from. So we wouldn't really save any work or code, unfortunately. I guess I am just a little worried that we end up with errors in the code that could have been solved by using a maintainer http library, but if it isn't feasible I guess not. Cheers, Jes
[Qemu-devel] Re: [PATCH] fix qruncom compilation problems
On 12/08/2010 01:49 PM, Paolo Bonzini wrote: Signed-off-by: Paolo Bonzinipbonz...@redhat.com --- I had this patch lying around but I don't think I ever got qruncom to work completely. Makefile.target |3 ++ tests/Makefile |7 ++-- tests/qruncom.c | 93 +++--- 3 files changed, 67 insertions(+), 36 deletions(-) diff --git a/Makefile.target b/Makefile.target index 5784844..4ac8f6f 100644 --- a/Makefile.target +++ b/Makefile.target @@ -339,6 +339,9 @@ obj-y += $(addprefix ../libdis/, $(libdis-y)) obj-y += $(libobj-y) obj-y += $(addprefix $(HWDIR)/, $(hw-obj-y)) +else # !CONFIG_SOFTMMU +libqemu.a: $(addprefix ../, $(common-obj-y)) $(libobj-y) $(addprefix ../libdis/, $(libdis-y)) + ar rc $@ $^ endif # CONFIG_SOFTMMU obj-y += $(addprefix ../, $(trace-obj-y)) diff --git a/tests/Makefile b/tests/Makefile index e43ec70..6dbeb6f 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -116,9 +116,10 @@ speed: sha1 sha1-i386 # broken test # NOTE: -fomit-frame-pointer is currently needed : this is a bug in libqemu -qruncom: qruncom.c ../ioport-user.c ../i386-user/libqemu.a - $(CC) $(CFLAGS) -fomit-frame-pointer $(LDFLAGS) -I../target-i386 -I.. -I../i386-user -I../fpu \ - -o $@ $(filter %.c, $^) -L../i386-user -lqemu -lm +qruncom: qruncom.c + #$(MAKE) -C ../i386-linux-user libqemu.a + $(CC) $(CFLAGS) -fomit-frame-pointer $(LDFLAGS) -I../target-i386 -I.. -I../linux-user -I../i386-linux-user -I../fpu \ + -o $@ $(filter %.c, $^) -L../i386-linux-user -lqemu -lm # arm test hello-arm: hello-arm.o diff --git a/tests/qruncom.c b/tests/qruncom.c index 079f7a2..66fc223 100644 --- a/tests/qruncom.c +++ b/tests/qruncom.c @@ -12,10 +12,68 @@ #includesignal.h #includemalloc.h +#define NEED_CPU_H 1 #include cpu.h //#define SIGTEST +unsigned long guest_base = 0; +int have_guest_base = 0; +int singlestep = 0; +unsigned long last_brk = 0; + +void cpu_outb(uint32_t addr, uint8_t val) +{ +fprintf(stderr, outb: port=0x%04PRIx32, data=%02PRIx8\n, +addr, val); +} + +void cpu_outw(uint32_t addr, uint16_t val) +{ +fprintf(stderr, outw: port=0x%04PRIx32, data=%04PRIx16\n, +addr, val); +} + +void cpu_outl(uint32_t addr, uint32_t val) +{ +fprintf(stderr, outl: port=0x%04PRIx32, data=%08PRIx32\n, +addr, val); +} + +uint8_t cpu_inb(uint32_t addr) +{ +fprintf(stderr, inb: port=0x%04PRIx32\n, addr); +return 0; +} + +uint16_t cpu_inw(uint32_t addr) +{ +fprintf(stderr, inw: port=0x%04PRIx32\n, addr); +return 0; +} + +uint32_t cpu_inl(uint32_t addr) +{ +fprintf(stderr, inl: port=0x%04PRIx32\n, addr); +return 0; +} + +void cpu_list_lock(void) +{ +} + +void cpu_list_unlock(void) +{ +} + +void mmap_lock(void) +{ +} + +void mmap_unlock(void) +{ +} + int cpu_get_pic_interrupt(CPUState *env) { return -1; @@ -44,26 +102,6 @@ static void set_idt(int n, unsigned int dpl) set_gate(idt_table + n, 0, dpl, 0, 0); } -void qemu_free(void *ptr) -{ -free(ptr); -} - -void *qemu_malloc(size_t size) -{ -return malloc(size); -} - -void *qemu_mallocz(size_t size) -{ -void *ptr; -ptr = qemu_malloc(size); -if (!ptr) -return NULL; -memset(ptr, 0, size); -return ptr; -} - void *qemu_vmalloc(size_t size) { return memalign(4096, size); @@ -74,17 +112,6 @@ void qemu_vfree(void *ptr) free(ptr); } -void qemu_printf(const char *fmt, ...) -{ -va_list ap; -va_start(ap, fmt); -vprintf(fmt, ap); -va_end(ap); -} - -/* XXX: this is a bug in helper2.c */ -int errno; - /**/ #define COM_BASE_ADDR0x10100 @@ -99,7 +126,7 @@ static void usage(void) static inline uint8_t *seg_to_linear(unsigned int seg, unsigned int reg) { -return (uint8_t *)((seg 4) + (reg 0x)); +return (uint8_t *)(uintptr_t) ((seg 4) + (reg 0x)); } static inline void pushw(CPUState *env, int val) @@ -241,7 +268,7 @@ int main(int argc, char **argv) case EXCP0D_GPF: { int int_num, ah; -int_num = *(uint8_t *)(env-segs[R_CS].base + env-eip + 1); +int_num = *(uint8_t *)(uintptr_t) (env-segs[R_CS].base + env-eip + 1); if (int_num != 0x21) goto unknown_int; ah = (env-regs[R_EAX] 8) 0xff; Hi! Thank you for your help! I've linked qemu-malloc.o and cutils.o together with qruncom.c and I managed to succesfully make it! here the make line: #$(MAKE) -C ../i386-linux-user libqemu.a $(CC) $(CFLAGS) -fomit-frame-pointer $(LDFLAGS) -I../target-i386 -I.. -I../linux-user -I../i386-linux-user -I../fpu \ -o $@ ../qemu-malloc.o ../cutils.o $(filter %.c, $^) -L../i386-linux-user -lqemu -lm Anyway running it with a com file as argument gave the error: mmap: Operation not permitted I
[Qemu-devel] Re: [RFC][PATCH v5 07/21] virtagent: add va.getfile RPC
On 12/07/10 17:00, Adam Litke wrote: Hi Jes, you raise some good points and pitfalls with the current getfile approach. I've been thinking about an alternative and am wondering what you (and others) think... First off, I think we should switch to a copyfile() API that allows us to avoid presenting the file contents to the user. Neither the human monitor nor the control monitor are designed to be file pagers. Let the user decide how to consume the data once it has been transferred. Now we don't need to care if the file is binary or text. The virtagent RPC protocol is bi-directional and supports asynchronous events. We can use these to implement a better copyfile RPC that can transfer larger files without wasting memory. The host issues a copyfile(guest-path, host-path) RPC. The immediate result of this call will indicate whether the guest is able to initiate the transfer. The guest will generate a series of events (offset, size, payload) until the entire contents has been transferred. The host and guest could negotiate the chunk size if necessary. Once the transfer is complete, the guest sends a final event to indicate this (file-size, 0). This interface could be integrated into the monitor with a pair of commands (va_copyfile and info va_copyfile), the former used to initiate transfers and the latter to check on the status. Thoughts on this? Hi Adam, This sounds a lot safer than the current approach. Intuitively I would think it should be the host controlling the copy, but otherwise it sounds good. Or is there a reason why the guest should control it? I think it is vital that we do it in a way where a copy cannot blow QEMU's memory consumption out of the water, but the approach you suggest seems to take care of that. Cheers, Jes
[Qemu-devel] [PATCH] disable sigcld handling before calling pclose()
When I use the command 'virsh save' to save the domain state, I receive the following error message: operation failed: Migration unexpectedly failed. I debug the qemu by adding some printf(), and find the function pclose() returns -1. I use strace to trace qemu, the log is as the following: == close(17) = 0 --- SIGCHLD (Child exited) @ 0 (0) --- wait4(-1, NULL, WNOHANG, NULL) = 22016 rt_sigreturn(0) = 0 wait4(22016, 0x7fff7f1034fc, 0, NULL) = -1 ECHILD (No child processes) == We wait the child twice: one is in signal SIGCHLD handling and the other one is in pclose(). We should disable sigcld handling before calling pclose(). Signed-off-by: Wen Congyang we...@cn.fujitsu.com --- os-posix.c | 19 +++ qemu-os-posix.h |2 ++ savevm.c|2 ++ 3 files changed, 23 insertions(+), 0 deletions(-) diff --git a/os-posix.c b/os-posix.c index 38c29d1..b163995 100644 --- a/os-posix.c +++ b/os-posix.c @@ -86,6 +86,25 @@ void os_setup_signal_handling(void) sigaction(SIGCHLD, act, NULL); } +void os_stop_sigchld_handling(void) +{ +struct sigaction act; + +memset(act, 0, sizeof(act)); +act.sa_handler = SIG_DFL; +sigaction(SIGCHLD, act, NULL); +} + +void os_resume_sigchld_handling(void) +{ +struct sigaction act; + +memset(act, 0, sizeof(act)); +act.sa_handler = sigchld_handler; +act.sa_flags = SA_NOCLDSTOP; +sigaction(SIGCHLD, act, NULL); +} + /* Find a likely location for support files using the location of the binary. For installed binaries this will be $bindir/../share/qemu. When running from the build tree this will be $bindir/../pc-bios. */ diff --git a/qemu-os-posix.h b/qemu-os-posix.h index 353f878..e819295 100644 --- a/qemu-os-posix.h +++ b/qemu-os-posix.h @@ -33,6 +33,8 @@ static inline void os_host_main_loop_wait(int *timeout) void os_set_line_buffering(void); void os_set_proc_name(const char *s); void os_setup_signal_handling(void); +void os_stop_sigchld_handling(void); +void os_resume_sigchld_handling(void); void os_daemonize(void); void os_setup_post(void); diff --git a/savevm.c b/savevm.c index d38f79e..08a5f88 100644 --- a/savevm.c +++ b/savevm.c @@ -234,7 +234,9 @@ static int stdio_pclose(void *opaque) { QEMUFileStdio *s = opaque; int ret; +os_stop_sigchld_handling(); ret = pclose(s-stdio_file); +os_resume_sigchld_handling(); qemu_free(s); return ret; } -- 1.7.1
[Qemu-devel] Re: [PATCH 1/6] qemu, kvm: Enable NMI support for user space irqchip
Am 09.12.2010 07:58, Lai Jiangshan wrote: Make use of the new KVM_NMI IOCTL to send NMIs into the KVM guest if the user space APIC emulation or some other source raised them. In that light, the subject is not absolutely correct. Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 7dfc357..c4ebe28 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -1417,6 +1417,14 @@ int kvm_arch_get_registers(CPUState *env) int kvm_arch_pre_run(CPUState *env, struct kvm_run *run) { +#ifdef KVM_CAP_USER_NMI +if (env-interrupt_request CPU_INTERRUPT_NMI) { +env-interrupt_request = ~CPU_INTERRUPT_NMI; +DPRINTF(injected NMI\n); +kvm_vcpu_ioctl(env, KVM_NMI); +} +#endif + /* Try to inject an interrupt if the guest can accept it */ if (run-ready_for_interrupt_injection (env-interrupt_request CPU_INTERRUPT_HARD) Actually, we already depend on KVM_CAP_DESTROY_MEMORY_REGION_WORKS which was introduced with 2.6.29 as well. I would suggest to simply extend the static configure check and avoid new #ifdefs in the code. Thanks for pushing this! Was obviously so trivial that it was forgotten... Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [Qemu-devel] [PATCH] ppc: kvm: fix signedness warning
On Wed, Dec 08, 2010 at 12:01:43PM +0100, Alexander Graf wrote: ping? I've applied this, thanks. On 25.11.2010, at 08:20, Alexander Graf wrote: I get a warning on a signed comparison with an unsigned variable, so let's make the variable signed and be happy. Signed-off-by: Alexander Graf ag...@suse.de --- target-ppc/kvm.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index 5cacef7..5caa07c 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -132,7 +132,7 @@ int kvm_arch_get_registers(CPUState *env) { struct kvm_regs regs; struct kvm_sregs sregs; -uint32_t i, ret; +int i, ret; ret = kvm_vcpu_ioctl(env, KVM_GET_REGS, regs); if (ret 0) -- 1.6.0.2
Re: [Qemu-devel] [PATCH] fix qruncom compilation problems
What is the reason to duplicate cpu_{in,out}[bwl]() instead of ioport-user.c? On Wed, Dec 08, 2010 at 01:49:11PM +0100, Paolo Bonzini wrote: Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- I had this patch lying around but I don't think I ever got qruncom to work completely. Makefile.target |3 ++ tests/Makefile |7 ++-- tests/qruncom.c | 93 +++--- 3 files changed, 67 insertions(+), 36 deletions(-) diff --git a/Makefile.target b/Makefile.target index 5784844..4ac8f6f 100644 --- a/Makefile.target +++ b/Makefile.target @@ -339,6 +339,9 @@ obj-y += $(addprefix ../libdis/, $(libdis-y)) obj-y += $(libobj-y) obj-y += $(addprefix $(HWDIR)/, $(hw-obj-y)) +else # !CONFIG_SOFTMMU +libqemu.a: $(addprefix ../, $(common-obj-y)) $(libobj-y) $(addprefix ../libdis/, $(libdis-y)) + ar rc $@ $^ endif # CONFIG_SOFTMMU obj-y += $(addprefix ../, $(trace-obj-y)) diff --git a/tests/Makefile b/tests/Makefile index e43ec70..6dbeb6f 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -116,9 +116,10 @@ speed: sha1 sha1-i386 # broken test # NOTE: -fomit-frame-pointer is currently needed : this is a bug in libqemu -qruncom: qruncom.c ../ioport-user.c ../i386-user/libqemu.a - $(CC) $(CFLAGS) -fomit-frame-pointer $(LDFLAGS) -I../target-i386 -I.. -I../i386-user -I../fpu \ - -o $@ $(filter %.c, $^) -L../i386-user -lqemu -lm +qruncom: qruncom.c + #$(MAKE) -C ../i386-linux-user libqemu.a + $(CC) $(CFLAGS) -fomit-frame-pointer $(LDFLAGS) -I../target-i386 -I.. -I../linux-user -I../i386-linux-user -I../fpu \ + -o $@ $(filter %.c, $^) -L../i386-linux-user -lqemu -lm # arm test hello-arm: hello-arm.o diff --git a/tests/qruncom.c b/tests/qruncom.c index 079f7a2..66fc223 100644 --- a/tests/qruncom.c +++ b/tests/qruncom.c @@ -12,10 +12,68 @@ #include signal.h #include malloc.h +#define NEED_CPU_H 1 #include cpu.h //#define SIGTEST +unsigned long guest_base = 0; +int have_guest_base = 0; +int singlestep = 0; +unsigned long last_brk = 0; + +void cpu_outb(uint32_t addr, uint8_t val) +{ +fprintf(stderr, outb: port=0x%04PRIx32, data=%02PRIx8\n, +addr, val); +} + +void cpu_outw(uint32_t addr, uint16_t val) +{ +fprintf(stderr, outw: port=0x%04PRIx32, data=%04PRIx16\n, +addr, val); +} + +void cpu_outl(uint32_t addr, uint32_t val) +{ +fprintf(stderr, outl: port=0x%04PRIx32, data=%08PRIx32\n, +addr, val); +} + +uint8_t cpu_inb(uint32_t addr) +{ +fprintf(stderr, inb: port=0x%04PRIx32\n, addr); +return 0; +} + +uint16_t cpu_inw(uint32_t addr) +{ +fprintf(stderr, inw: port=0x%04PRIx32\n, addr); +return 0; +} + +uint32_t cpu_inl(uint32_t addr) +{ +fprintf(stderr, inl: port=0x%04PRIx32\n, addr); +return 0; +} + +void cpu_list_lock(void) +{ +} + +void cpu_list_unlock(void) +{ +} + +void mmap_lock(void) +{ +} + +void mmap_unlock(void) +{ +} + int cpu_get_pic_interrupt(CPUState *env) { return -1; @@ -44,26 +102,6 @@ static void set_idt(int n, unsigned int dpl) set_gate(idt_table + n, 0, dpl, 0, 0); } -void qemu_free(void *ptr) -{ -free(ptr); -} - -void *qemu_malloc(size_t size) -{ -return malloc(size); -} - -void *qemu_mallocz(size_t size) -{ -void *ptr; -ptr = qemu_malloc(size); -if (!ptr) -return NULL; -memset(ptr, 0, size); -return ptr; -} - void *qemu_vmalloc(size_t size) { return memalign(4096, size); @@ -74,17 +112,6 @@ void qemu_vfree(void *ptr) free(ptr); } -void qemu_printf(const char *fmt, ...) -{ -va_list ap; -va_start(ap, fmt); -vprintf(fmt, ap); -va_end(ap); -} - -/* XXX: this is a bug in helper2.c */ -int errno; - /**/ #define COM_BASE_ADDR0x10100 @@ -99,7 +126,7 @@ static void usage(void) static inline uint8_t *seg_to_linear(unsigned int seg, unsigned int reg) { -return (uint8_t *)((seg 4) + (reg 0x)); +return (uint8_t *)(uintptr_t) ((seg 4) + (reg 0x)); } static inline void pushw(CPUState *env, int val) @@ -241,7 +268,7 @@ int main(int argc, char **argv) case EXCP0D_GPF: { int int_num, ah; -int_num = *(uint8_t *)(env-segs[R_CS].base + env-eip + 1); +int_num = *(uint8_t *)(uintptr_t) (env-segs[R_CS].base + env-eip + 1); if (int_num != 0x21) goto unknown_int; ah = (env-regs[R_EAX] 8) 0xff; -- 1.7.3.2 -- yamahata
[Qemu-devel] Re: [PATCH 1/6] pci: untangle pci/msi dependency
On Sat, Dec 04, 2010 at 02:35:53PM +0100, Paolo Bonzini wrote: On 12/02/2010 11:54 PM, Michael S. Tsirkin wrote: +bool assert = pcie_aer_root_does_trigger(root_cmd_set, root_status); Risky variable name, I think it would fail if someone includes assert.h. Paolo We already do, it does not seem to fail.
Re: [Qemu-devel] [PATCH] fix qruncom compilation problems
On 12/09/2010 04:32 AM, Isaku Yamahata wrote: What is the reason to duplicate cpu_{in,out}[bwl]() instead of ioport-user.c? That's the reason why I hadn't submitted the patch so far, it's not really finished. I also wanted to remove the need for mmap(MAP_FIXED). Paolo
Re: [Qemu-devel] [PATCH 1/6] [RFC] Emulation of GRLIB GPTimer as defined in GRLIB IP Core User's Manual.
On 12/08/2010 11:51 PM, Edgar E. Iglesias wrote: On Mon, Dec 06, 2010 at 10:26:02AM +0100, Fabien Chouteau wrote: Signed-off-by: Fabien Chouteauchout...@adacore.com --- hw/grlib_gptimer.c | 448 1 files changed, 448 insertions(+), 0 deletions(-) diff --git a/hw/grlib_gptimer.c b/hw/grlib_gptimer.c new file mode 100644 index 000..41edbe4 --- /dev/null +++ b/hw/grlib_gptimer.c @@ -0,0 +1,448 @@ +/* + * QEMU GRLIB GPTimer Emulator + * + * Copyright (c) 2010 AdaCore + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the Software), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include sysbus.h +#include qemu-timer.h + +#include grlib.h + +/* #define DEBUG_TIMER */ + +#ifdef DEBUG_TIMER +#define DPRINTF(fmt, ...) \ +do { printf(GPTIMER: fmt , ## __VA_ARGS__); } while (0) +#else +#define DPRINTF(fmt, ...) +#endif + +#define UNIT_REG_SIZE16 /* Size of memory mapped regs for the unit */ +#define GPTIMER_REG_SIZE 16 /* Size of memory mapped regs for a GPTimer */ + +#define GPTIMER_MAX_TIMERS 8 + +/* GPTimer Config register fields */ +#define GPTIMER_ENABLE (1 0) +#define GPTIMER_RESTART (1 1) +#define GPTIMER_LOAD(1 2) +#define GPTIMER_INT_ENABLE (1 3) +#define GPTIMER_INT_PENDING (1 4) +#define GPTIMER_CHAIN (1 5) /* Not supported */ +#define GPTIMER_DEBUG_HALT (1 6) /* Not supported */ + +/* Memory mapped register offsets */ +#define SCALER_OFFSET 0x00 +#define SCALER_RELOAD_OFFSET 0x04 +#define CONFIG_OFFSET 0x08 +#define COUNTER_OFFSET0x00 +#define COUNTER_RELOAD_OFFSET 0x04 +#define TIMER_BASE0x10 + +typedef struct GPTimer GPTimer; +typedef struct GPTimerUnit GPTimerUnit; + +struct GPTimer +{ +QEMUBH *bh; +struct ptimer_state *ptimer; + +qemu_irq irq; +int id; +GPTimerUnit *unit; + +/* registers */ +uint32_t counter; +uint32_t reload; +uint32_t config; +}; + +struct GPTimerUnit +{ +SysBusDevice busdev; + +uint32_t nr_timers; /* Number of timers available */ +uint32_t freq_hz; /* System frequency */ +uint32_t irq_line; /* Base irq line */ + +GPTimer *timers; + +/* registers */ +uint32_t scaler; +uint32_t reload; +uint32_t config; +}; + +DeviceState *grlib_gptimer_create(target_phys_addr_t base, + uint32_tnr_timers, + uint32_tfreq, + qemu_irq *cpu_irqs, + int base_irq) +{ +DeviceState *dev; +int i; + +dev = qdev_create(NULL, grlib,gptimer); +qdev_prop_set_uint32(dev, nr-timers, nr_timers); +qdev_prop_set_uint32(dev, frequency, freq); +qdev_prop_set_uint32(dev, irq-line, base_irq); + +if (qdev_init(dev)) { +return NULL; +} + +sysbus_mmio_map(sysbus_from_qdev(dev), 0, base); + +for (i = 0; i nr_timers; i++) +sysbus_connect_irq(sysbus_from_qdev(dev), i, cpu_irqs[base_irq + i]); + +return dev; +} + +static void grlib_gptimer_enable(GPTimer *timer) +{ +assert(timer != NULL); + +DPRINTF(%s id:%d\n, __func__, timer-id); + +ptimer_stop(timer-ptimer); + +if (!(timer-config GPTIMER_ENABLE)) { +/* Timer disabled */ +DPRINTF(%s id:%d Timer disabled (config 0x%x)\n, __func__, +timer-id, timer-config); +return; +} + +/* ptimer is triggered when the counter reach 0 but GPTimer is triggered at + underflow. Set count + 1 to simulate the GPTimer behavior. */ + +DPRINTF(%s id:%d set count 0x%x and run\n, +__func__, +timer-id, +timer-counter + 1); + +ptimer_set_count(timer-ptimer, timer-counter + 1); +ptimer_run(timer-ptimer, 1); +} + +static void grlib_gptimer_restart(GPTimer *timer) +{ +assert(timer
[Qemu-devel] [PULL 00/14] Block patches
The following changes since commit 138b38b61bf92d4e9588acf934e532499c94e185: ppc: kvm: fix signedness warning (2010-12-08 21:30:19 +0100) are available in the git repository at: git://repo.or.cz/qemu/kevin.git for-anthony Christian Brunner (1): ceph/rbd block driver for qemu-kvm Jes Sorensen (8): Add missing tracing to qemu_mallocz() Use qemu_mallocz() instead of calloc() in img_convert() img_convert(): Only try to free bs[] entries if bs is valid. Consolidate printing of block driver options Fix formatting and missing braces in qemu-img.c Fail if detecting an unknown option Make error handling more consistent in img_create() and img_resize() qemu-img: Deprecate obsolete -6 and -e options Stefan Hajnoczi (5): block: Make bdrv_create_file() ':' handling consistent qemu-option: Don't reinvent append_option_parameters() qemu-option: Fix parse_option_parameters() documentation typo qemu-img: Free option parameter lists in img_create() qemu-img: Fail creation if backing format is invalid Makefile.objs |1 + block.c |2 +- block/rbd.c | 1059 + block/rbd_types.h | 71 block_int.h |1 - configure | 52 +++ qemu-img.c| 247 - qemu-malloc.c |5 +- qemu-option.c | 13 +- 9 files changed, 1344 insertions(+), 107 deletions(-) create mode 100644 block/rbd.c create mode 100644 block/rbd_types.h
[Qemu-devel] [PATCH 03/14] Use qemu_mallocz() instead of calloc() in img_convert()
From: Jes Sorensen jes.soren...@redhat.com Signed-off-by: Jes Sorensen jes.soren...@redhat.com Signed-off-by: Kevin Wolf kw...@redhat.com --- qemu-img.c |8 ++-- 1 files changed, 2 insertions(+), 6 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index fa77ac0..eca99c4 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -699,11 +699,7 @@ static int img_convert(int argc, char **argv) return 1; } -bs = calloc(bs_n, sizeof(BlockDriverState *)); -if (!bs) { -error(Out of memory); -return 1; -} +bs = qemu_mallocz(bs_n * sizeof(BlockDriverState *)); total_sectors = 0; for (bs_i = 0; bs_i bs_n; bs_i++) { @@ -983,7 +979,7 @@ out: bdrv_delete(bs[bs_i]); } } -free(bs); +qemu_free(bs); if (ret) { return 1; } -- 1.7.2.3
[Qemu-devel] [Bug 427612] Re: kvm sends caps lock key up event twice
This bug was fixed in the package qemu-kvm - 0.12.5+noroms-0ubuntu7.1 --- qemu-kvm (0.12.5+noroms-0ubuntu7.1) maverick-proposed; urgency=low * Add caps-lock-key-up-event.patch to enable normal up/down events for Caps-Lock and Num-Lock keys by setting SDL_DISABLE_LOCK_KEYS (which requires SDL 1.2.14). This fixes handling of capslock when capslock is mapped to something else in host system. (LP: #427612) -- Benjamin Drung bdr...@ubuntu.com Wed, 24 Nov 2010 15:35:10 +0100 ** Changed in: qemu-kvm (Ubuntu Maverick) Status: Fix Committed = Fix Released -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/427612 Title: kvm sends caps lock key up event twice Status in QEMU: New Status in “libsdl1.2” package in Ubuntu: Invalid Status in “qemu-kvm” package in Ubuntu: Fix Released Status in “libsdl1.2” source package in Maverick: Invalid Status in “qemu-kvm” source package in Maverick: Fix Released Status in “libsdl1.2” package in Debian: Fix Released Bug description: Binary package hint: qemu-kvm I have set the keyboard layout to German NEO 2 [1] in the host and the client (both current karmic). The caps lock is used as modifier (similar to shift) in NEO. When I press caps lock + t, then the client prints a t instead of a -. A caps lock key up event is sent to the client before I release the caps lock key. [1] http://www.neo-layout.org/ ProblemType: Bug Architecture: amd64 Date: Fri Sep 11 01:38:58 2009 DistroRelease: Ubuntu 9.10 KvmCmdLine: Error: command ['ps', '-C', 'kvm', '-F'] failed with exit code 1: UIDPID PPID CSZ RSS PSR STIME TTY TIME CMD Package: qemu-kvm 0.11.0~rc2-0ubuntu2 PccardctlIdent: PccardctlStatus: ProcCmdLine: BOOT_IMAGE=/boot/vmlinuz-2.6.31-10-generic root=UUID=37b01f5a-a578-49d6-a812-f166b103e68a ro quiet splash ProcEnviron: LANG=de_DE.UTF-8 SHELL=/bin/bash ProcVersionSignature: Ubuntu 2.6.31-10.31-generic SourcePackage: qemu-kvm Uname: Linux 2.6.31-10-generic x86_64 dmi.bios.date: 07/15/2009 dmi.bios.vendor: Intel Corp. dmi.bios.version: DPP3510J.86A.0572.2009.0715.2346 dmi.board.asset.tag: Base Board Asset Tag dmi.board.name: DG33TL dmi.board.vendor: Intel Corporation dmi.board.version: AAD89517-802 dmi.chassis.type: 3 dmi.modalias: dmi:bvnIntelCorp.:bvrDPP3510J.86A.0572.2009.0715.2346:bd07/15/2009:svn:pn:pvr:rvnIntelCorporation:rnDG33TL:rvrAAD89517-802:cvn:ct3:cvr: TEST CASE: Select NEO2 as keyboard layout in your guest system and press 'caps lock' + 't'. A '-' should appear.
[Qemu-devel] [PATCH 4/6] qemu,qmp: QError: New QERR_TOO_MANY_KEYS
Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- diff --git a/qerror.c b/qerror.c index a7ef758..fd66d2a 100644 --- a/qerror.c +++ b/qerror.c @@ -197,6 +197,10 @@ static const QErrorStringTable qerror_table[] = { .desc = Too many open files, }, { +.error_fmt = QERR_TOO_MANY_KEYS, +.desc = Too many keys, +}, +{ .error_fmt = QERR_UNDEFINED_ERROR, .desc = An undefined error has ocurred, }, diff --git a/qerror.h b/qerror.h index 4fa95ef..7f56f12 100644 --- a/qerror.h +++ b/qerror.h @@ -162,6 +162,9 @@ QError *qobject_to_qerror(const QObject *obj); #define QERR_TOO_MANY_FILES \ { 'class': 'TooManyFiles', 'data': {} } +#define QERR_TOO_MANY_KEYS \ +{ 'class': 'TooManyKeys', 'data': {} } + #define QERR_UNDEFINED_ERROR \ { 'class': 'UndefinedError', 'data': {} }
[Qemu-devel] [PATCH 02/14] Add missing tracing to qemu_mallocz()
From: Jes Sorensen jes.soren...@redhat.com Signed-off-by: Jes Sorensen jes.soren...@redhat.com Signed-off-by: Kevin Wolf kw...@redhat.com --- qemu-malloc.c |5 - 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/qemu-malloc.c b/qemu-malloc.c index 28fb05a..b9b3851 100644 --- a/qemu-malloc.c +++ b/qemu-malloc.c @@ -64,10 +64,13 @@ void *qemu_realloc(void *ptr, size_t size) void *qemu_mallocz(size_t size) { +void *ptr; if (!size !allow_zero_malloc()) { abort(); } -return qemu_oom_check(calloc(1, size ? size : 1)); +ptr = qemu_oom_check(calloc(1, size ? size : 1)); +trace_qemu_malloc(size, ptr); +return ptr; } char *qemu_strdup(const char *str) -- 1.7.2.3
[Qemu-devel] [PATCH 01/14] block: Make bdrv_create_file() ':' handling consistent
From: Stefan Hajnoczi stefa...@linux.vnet.ibm.com Filenames may start with protocol: to explicitly use a protocol like nbd. Filenames with unknown protocols are rejected in most of QEMU except for bdrv_create_file(). Even if a file with an invalid filename can be created, QEMU cannot use it since all the other relevant functions reject such paths. Make bdrv_create_file() consistent. Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com Signed-off-by: Kevin Wolf kw...@redhat.com --- block.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/block.c b/block.c index 63effd8..e7a986c 100644 --- a/block.c +++ b/block.c @@ -215,7 +215,7 @@ int bdrv_create_file(const char* filename, QEMUOptionParameter *options) drv = bdrv_find_protocol(filename); if (drv == NULL) { -drv = bdrv_find_format(file); +return -ENOENT; } return bdrv_create(drv, filename, options); -- 1.7.2.3
[Qemu-devel] [PATCH 07/14] Fail if detecting an unknown option
From: Jes Sorensen jes.soren...@redhat.com This patch changes qemu-img to exit if an unknown option is detected, instead of trying to continue with a set of arguments which may be incorrect. Signed-off-by: Jes Sorensen jes.soren...@redhat.com Signed-off-by: Kevin Wolf kw...@redhat.com --- qemu-img.c |8 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index cc77048..6fd52e9 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -309,6 +309,7 @@ static int img_create(int argc, char **argv) break; } switch(c) { +case '?': case 'h': help(); break; @@ -477,6 +478,7 @@ static int img_check(int argc, char **argv) break; } switch(c) { +case '?': case 'h': help(); break; @@ -555,6 +557,7 @@ static int img_commit(int argc, char **argv) break; } switch(c) { +case '?': case 'h': help(); break; @@ -693,6 +696,7 @@ static int img_convert(int argc, char **argv) break; } switch(c) { +case '?': case 'h': help(); break; @@ -1097,6 +1101,7 @@ static int img_info(int argc, char **argv) break; } switch(c) { +case '?': case 'h': help(); break; @@ -1174,6 +1179,7 @@ static int img_snapshot(int argc, char **argv) break; } switch(c) { +case '?': case 'h': help(); return 0; @@ -1289,6 +1295,7 @@ static int img_rebase(int argc, char **argv) break; } switch(c) { +case '?': case 'h': help(); return 0; @@ -1503,6 +1510,7 @@ static int img_resize(int argc, char **argv) break; } switch(c) { +case '?': case 'h': help(); break; -- 1.7.2.3
[Qemu-devel] [Bug 687733] Re: Linux KSM not compiled in (MADV_MERGEABLE always undef)
To clarify: custom kernel == vanilla Linux kernel, i.e. not distribution kernel. -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/687733 Title: Linux KSM not compiled in (MADV_MERGEABLE always undef) Status in QEMU: New Bug description: Linux KSM support is not enabled because MADV_MERGEABLE remains undefined. It seems that asm-generic/mman-common.h is not included. Maybe some kind of header dependency problem? Adding #include asm-generic/mman-common.h to exec.c of qemu-kvm-0.13.0 enables use of KSM and values change in /sys/kernel/mm/ksm/. Tested under CentOS 5.5 with custom kernel 2.6.32.26 and OpenSUSE 11.2 with custom kernel 2.6.36.1, both x86_64 platform. Please note that I configure with--kerneldir=/lib/modules/2.6.../build and even --extra-cflags=-I/lib/modules/2.6.../build/include.
[Qemu-devel] Re: [PATTCH v2 0/6] pcie aer fixes
On Wed, Dec 08, 2010 at 05:46:22PM +0900, Isaku Yamahata wrote: I respined the patch series by mst for bisectability. Applied, thanks. Changes v1 - v2: - reorder patches for bisectability - s/assert/trigger/ to avoid name conflict - abort() instead of assert(0) Original patch description: Here are a bunch of fixes and cleanups to aer interrupt injection. Compile tested only, issues were found by reading the code and spec. Michael S. Tsirkin (6): pci: untangle pci/msi dependency Makefile: make msix/msi depend on CONFIG_PCI pci/aer: fix error injection pci/aer: fix interrupt on config write pci/aer: remove dead code pci/aer: factor out common code Makefile.objs |3 +- hw/pci.c | 19 -- hw/pci.h |3 -- hw/pcie.c |8 +++-- hw/pcie_aer.c | 111 ++-- 5 files changed, 59 insertions(+), 85 deletions(-)
[Qemu-devel] [PATCH 09/14] ceph/rbd block driver for qemu-kvm
From: Christian Brunner c...@muc.de RBD is an block driver for the distributed file system Ceph (http://ceph.newdream.net/). This driver uses librados (which is part of the Ceph server) for direct access to the Ceph object store and is running entirely in userspace (Yehuda also wrote a driver for the linux kernel, that can be used to access rbd volumes as a block device). Signed-off-by: Yehuda Sadeh yeh...@hq.newdream.net Signed-off-by: Christian Brunner c...@muc.de Reviewed-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com Signed-off-by: Kevin Wolf kw...@redhat.com --- Makefile.objs |1 + block/rbd.c | 1059 + block/rbd_types.h | 71 configure | 52 +++ 4 files changed, 1183 insertions(+), 0 deletions(-) create mode 100644 block/rbd.c create mode 100644 block/rbd_types.h diff --git a/Makefile.objs b/Makefile.objs index 04625eb..5c56a07 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -24,6 +24,7 @@ block-nested-y += parallels.o nbd.o blkdebug.o sheepdog.o blkverify.o block-nested-$(CONFIG_WIN32) += raw-win32.o block-nested-$(CONFIG_POSIX) += raw-posix.o block-nested-$(CONFIG_CURL) += curl.o +block-nested-$(CONFIG_RBD) += rbd.o block-obj-y += $(addprefix block/, $(block-nested-y)) diff --git a/block/rbd.c b/block/rbd.c new file mode 100644 index 000..249a590 --- /dev/null +++ b/block/rbd.c @@ -0,0 +1,1059 @@ +/* + * QEMU Block driver for RADOS (Ceph) + * + * Copyright (C) 2010 Christian Brunner c...@muc.de + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#include qemu-common.h +#include qemu-error.h + +#include rbd_types.h +#include block_int.h + +#include rados/librados.h + + + +/* + * When specifying the image filename use: + * + * rbd:poolname/devicename + * + * poolname must be the name of an existing rados pool + * + * devicename is the basename for all objects used to + * emulate the raw device. + * + * Metadata information (image size, ...) is stored in an + * object with the name devicename.rbd. + * + * The raw device is split into 4MB sized objects by default. + * The sequencenumber is encoded in a 12 byte long hex-string, + * and is attached to the devicename, separated by a dot. + * e.g. devicename.1234567890ab + * + */ + +#define OBJ_MAX_SIZE (1UL OBJ_DEFAULT_OBJ_ORDER) + +typedef struct RBDAIOCB { +BlockDriverAIOCB common; +QEMUBH *bh; +int ret; +QEMUIOVector *qiov; +char *bounce; +int write; +int64_t sector_num; +int aiocnt; +int error; +struct BDRVRBDState *s; +int cancelled; +} RBDAIOCB; + +typedef struct RADOSCB { +int rcbid; +RBDAIOCB *acb; +struct BDRVRBDState *s; +int done; +int64_t segsize; +char *buf; +int ret; +} RADOSCB; + +#define RBD_FD_READ 0 +#define RBD_FD_WRITE 1 + +typedef struct BDRVRBDState { +int fds[2]; +rados_pool_t pool; +rados_pool_t header_pool; +char name[RBD_MAX_OBJ_NAME_SIZE]; +char block_name[RBD_MAX_BLOCK_NAME_SIZE]; +uint64_t size; +uint64_t objsize; +int qemu_aio_count; +int event_reader_pos; +RADOSCB *event_rcb; +} BDRVRBDState; + +typedef struct rbd_obj_header_ondisk RbdHeader1; + +static void rbd_aio_bh_cb(void *opaque); + +static int rbd_next_tok(char *dst, int dst_len, +char *src, char delim, +const char *name, +char **p) +{ +int l; +char *end; + +*p = NULL; + +if (delim != '\0') { +end = strchr(src, delim); +if (end) { +*p = end + 1; +*end = '\0'; +} +} +l = strlen(src); +if (l = dst_len) { +error_report(%s too long, name); +return -EINVAL; +} else if (l == 0) { +error_report(%s too short, name); +return -EINVAL; +} + +pstrcpy(dst, dst_len, src); + +return 0; +} + +static int rbd_parsename(const char *filename, + char *pool, int pool_len, + char *snap, int snap_len, + char *name, int name_len) +{ +const char *start; +char *p, *buf; +int ret; + +if (!strstart(filename, rbd:, start)) { +return -EINVAL; +} + +buf = qemu_strdup(start); +p = buf; + +ret = rbd_next_tok(pool, pool_len, p, '/', pool name, p); +if (ret 0 || !p) { +ret = -EINVAL; +goto done; +} +ret = rbd_next_tok(name, name_len, p, '@', object name, p); +if (ret 0) { +goto done; +} +if (!p) { +*snap = '\0'; +goto done; +} + +ret = rbd_next_tok(snap, snap_len, p, '\0', snap name, p); + +done: +qemu_free(buf); +return ret; +} + +static int create_tmap_op(uint8_t op, const char *name, char **tmap_desc) +{ +uint32_t len = strlen(name); +uint32_t len_le = cpu_to_le32(len); +/* total_len = encoding op + name
[Qemu-devel] [PATCH 2/2] Make img_create() use strtosz_suffix()
From: Jes Sorensen jes.soren...@redhat.com This reestablished the old default of using bytes as the default for the size argument, and not MB as we do in pretty much every other place. Signed-off-by: Jes Sorensen jes.soren...@redhat.com --- qemu-img.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 9a5e7e1..603bdb3 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -331,7 +331,7 @@ static int img_create(int argc, char **argv) /* Get image size, if specified */ if (optind argc) { ssize_t sval; -sval = strtosz(argv[optind++], NULL); +sval = strtosz_suffix(argv[optind++], NULL, STRTOSZ_DEFSUFFIX_B); if (sval 0) { error(Invalid image size specified! You may use k, M, G or T suffixes for ); -- 1.7.3.2
[Qemu-devel] [PATCH v3 1/1] qemu-img.c: Clean up handling of image size in img_create()
From: Jes Sorensen jes.soren...@redhat.com This cleans up the handling of image size in img_create() by parsing the value early, and then only setting it once if a value has been added as the last argument to the command line. Signed-off-by: Jes Sorensen jes.soren...@redhat.com --- qemu-img.c | 23 +-- 1 files changed, 17 insertions(+), 6 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index d146d8c..d9667a2 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -282,6 +282,7 @@ static int add_old_style_options(const char *fmt, QEMUOptionParameter *list, static int img_create(int argc, char **argv) { int c, ret = 0; +uint64_t img_size = -1; const char *fmt = raw; const char *base_fmt = NULL; const char *filename; @@ -329,6 +330,20 @@ static int img_create(int argc, char **argv) } filename = argv[optind++]; +/* Get image size, if specified */ +if (optind argc) { +ssize_t sval; +sval = strtosz(argv[optind++], NULL); +if (sval 0) { +error(Invalid image size specified! You may use k, M, G or + T suffixes for ); +error(kilobytes, megabytes, gigabytes and terabytes.); +ret = -1; +goto out; +} +img_size = (uint64_t)sval; +} + if (options !strcmp(options, ?)) { ret = print_block_option_help(filename, fmt); goto out; @@ -356,7 +371,8 @@ static int img_create(int argc, char **argv) /* Create parameter list with default values */ param = parse_option_parameters(, create_options, param); -set_option_parameter_int(param, BLOCK_OPT_SIZE, -1); + +set_option_parameter_int(param, BLOCK_OPT_SIZE, img_size); /* Parse -o options */ if (options) { @@ -368,11 +384,6 @@ static int img_create(int argc, char **argv) } } -/* Add size to parameters */ -if (optind argc) { -set_option_parameter(param, BLOCK_OPT_SIZE, argv[optind++]); -} - /* Add old-style options to parameters */ ret = add_old_style_options(fmt, param, base_filename, base_fmt); if (ret 0) { -- 1.7.3.2
[Qemu-devel] Re: [PATCH] kvm: x86: Save/restore error_code
Jason Wang jasow...@redhat.com wrote: The saving and restoring of error_code seems lost and convert the error_code to uint32_t. Signed-off-by: Jason Wang jasow...@redhat.com --- target-i386/cpu.h |4 ++-- target-i386/machine.c |2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) It should be a new subsection. The test is if has_error_code != 0 according to gleb. Later, Juan. diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 06e40f3..c990db9 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -688,7 +688,7 @@ typedef struct CPUX86State { uint64_t pat; /* exception/interrupt handling */ -int error_code; +uint32_t error_code; int exception_is_int; target_ulong exception_next_eip; target_ulong dr[8]; /* debug registers */ @@ -933,7 +933,7 @@ uint64_t cpu_get_tsc(CPUX86State *env); #define cpu_list_id x86_cpu_list #define cpudef_setup x86_cpudef_setup -#define CPU_SAVE_VERSION 12 +#define CPU_SAVE_VERSION 13 /* MMU modes definitions */ #define MMU_MODE0_SUFFIX _kernel diff --git a/target-i386/machine.c b/target-i386/machine.c index d78eceb..0e467da 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -491,6 +491,8 @@ static const VMStateDescription vmstate_cpu = { VMSTATE_UINT64_V(xcr0, CPUState, 12), VMSTATE_UINT64_V(xstate_bv, CPUState, 12), VMSTATE_YMMH_REGS_VARS(ymmh_regs, CPUState, CPU_NB_REGS, 12), + +VMSTATE_UINT32_V(error_code, CPUState, 13), VMSTATE_END_OF_LIST() /* The above list is not sorted /wrt version numbers, watch out! */ },
[Qemu-devel] [PATCH 1/2] Introduce strtosz_suffix()
From: Jes Sorensen jes.soren...@redhat.com This introduces strtosz_suffix() which allows the caller to specify a default suffix in case the non default of MB is wanted. strtosz() is kept as a wrapper for strtosz_suffix() which keeps it's current default of MB. Signed-off-by: Jes Sorensen jes.soren...@redhat.com --- cutils.c | 17 ++--- qemu-common.h |7 +++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/cutils.c b/cutils.c index 28089aa..1d24d9a 100644 --- a/cutils.c +++ b/cutils.c @@ -291,10 +291,10 @@ int fcntl_setfl(int fd, int flag) * value must be terminated by whitespace, ',' or '\0'. Return -1 on * error. */ -ssize_t strtosz(const char *nptr, char **end) +ssize_t strtosz_suffix(const char *nptr, char **end, const char default_suffix) { ssize_t retval = -1; -char *endptr, c; +char *endptr, c, d; int mul_required = 0; double val, mul, integral, fraction; @@ -313,10 +313,16 @@ ssize_t strtosz(const char *nptr, char **end) * part of a multi token argument. */ c = *endptr; +d = c; if (isspace(c) || c == '\0' || c == ',') { c = 0; +if (default_suffix) { +d = default_suffix; +} else { +d = c; +} } -switch (c) { +switch (d) { case 'B': case 'b': mul = 1; @@ -371,3 +377,8 @@ fail: return retval; } + +ssize_t strtosz(const char *nptr, char **end) +{ +return strtosz_suffix(nptr, end, 0); +} diff --git a/qemu-common.h b/qemu-common.h index de82c2e..dc44cd6 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -149,7 +149,14 @@ time_t mktimegm(struct tm *tm); int qemu_fls(int i); int qemu_fdatasync(int fd); int fcntl_setfl(int fd, int flag); + +#define STRTOSZ_DEFSUFFIX_TB 'T' +#define STRTOSZ_DEFSUFFIX_GB 'G' +#define STRTOSZ_DEFSUFFIX_MB 'M' +#define STRTOSZ_DEFSUFFIX_KB 'K' +#define STRTOSZ_DEFSUFFIX_B'B' ssize_t strtosz(const char *nptr, char **end); +ssize_t strtosz_suffix(const char *nptr, char **end, const char); /* path.c */ void init_paths(const char *prefix); -- 1.7.3.2
[Qemu-devel] [PATCH 5/6] qemu,qmp: QError: New QERR_UNKNOWN_KEY
Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- diff --git a/qerror.c b/qerror.c index fd66d2a..07b4cfc 100644 --- a/qerror.c +++ b/qerror.c @@ -205,6 +205,10 @@ static const QErrorStringTable qerror_table[] = { .desc = An undefined error has ocurred, }, { +.error_fmt = QERR_UNKNOWN_KEY, +.desc = Unknown key: '%(name)', +}, +{ .error_fmt = QERR_VNC_SERVER_FAILED, .desc = Could not start VNC server on %(target), }, diff --git a/qerror.h b/qerror.h index 7f56f12..cf3ab8f 100644 --- a/qerror.h +++ b/qerror.h @@ -168,6 +168,9 @@ QError *qobject_to_qerror(const QObject *obj); #define QERR_UNDEFINED_ERROR \ { 'class': 'UndefinedError', 'data': {} } +#define QERR_UNKNOWN_KEY \ +{ 'class': 'UnknownKey', 'data': { 'name': %s } } + #define QERR_VNC_SERVER_FAILED \ { 'class': 'VNCServerFailed', 'data': { 'target': %s } }
Re: [Qemu-devel] [PATCH 2/6] [RFC] Emulation of GRLIB IRQMP as defined in GRLIB IP Core User's Manual.
On 12/09/2010 12:06 PM, Edgar E. Iglesias wrote: On Thu, Dec 09, 2010 at 12:03:35PM +0100, Fabien Chouteau wrote: On 12/09/2010 11:32 AM, Edgar E. Iglesias wrote: On Mon, Dec 06, 2010 at 10:26:03AM +0100, Fabien Chouteau wrote: Signed-off-by: Fabien Chouteauchout...@adacore.com --- hw/grlib_irqmp.c | 416 ++ 1 files changed, 416 insertions(+), 0 deletions(-) diff --git a/hw/grlib_irqmp.c b/hw/grlib_irqmp.c new file mode 100644 index 000..69e1553 --- /dev/null +++ b/hw/grlib_irqmp.c @@ -0,0 +1,416 @@ +/* + * QEMU GRLIB IRQMP Emulator + * + * (Multiprocessor and extended interrupt not supported) + * + * Copyright (c) 2010 AdaCore + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the Software), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include sysbus.h +#include cpu.h + +#include grlib.h + +/* #define DEBUG_IRQ */ + +#ifdef DEBUG_IRQ +#define DPRINTF(fmt, ...) \ +do { printf(IRQMP: fmt , ## __VA_ARGS__); } while (0) +#else +#define DPRINTF(fmt, ...) +#endif + +#define IRQMP_MAX_CPU 16 +#define IRQMP_REG_SIZE 256 /* Size of memory mapped registers */ + +/* Memory mapped register offsets */ +#define LEVEL_OFFSET 0x00 +#define PENDING_OFFSET 0x04 +#define FORCE0_OFFSET0x08 +#define CLEAR_OFFSET 0x0C +#define MP_STATUS_OFFSET 0x10 +#define BROADCAST_OFFSET 0x14 +#define MASK_OFFSET 0x40 +#define FORCE_OFFSET 0x80 +#define EXTENDED_OFFSET 0xC0 + +typedef struct IRQMP +{ +SysBusDevice busdev; + +CPUSPARCState *env; +} IRQMP; + +typedef struct IRQMPState +{ +uint32_t level; +uint32_t pending; +uint32_t clear; +uint32_t broadcast; + +uint32_t mask[IRQMP_MAX_CPU]; +uint32_t force[IRQMP_MAX_CPU]; +uint32_t extended[IRQMP_MAX_CPU]; + +IRQMP*parent; +} IRQMPState; + +IRQMPState grlib_irqmp_state; + +void grlib_irqmp_set_irq(void *opaque, int irq, int level); + +DeviceState *grlib_irqmp_create(target_phys_addr_t base, +CPUState*env, +qemu_irq **cpu_irqs, +uint32_t nr_irqs) +{ +DeviceState *dev; + +assert(cpu_irqs != NULL); + +dev = qdev_create(NULL, grlib,irqmp); +qdev_prop_set_ptr(dev, cpustate, env); + +if (qdev_init(dev)) { +return NULL; +} + +sysbus_mmio_map(sysbus_from_qdev(dev), 0, base); + +*cpu_irqs = qemu_allocate_irqs(grlib_irqmp_set_irq, +grlib_irqmp_state, + nr_irqs); + +return dev; +} + +static void grlib_irqmp_check_irqs(CPUState *env) +{ +uint32_t pend = 0; +uint32_t level0 = 0; +uint32_t level1 = 0; + +assert(env != NULL); + +/* IRQ for CPU 0 (no SMP support) */ +pend = (grlib_irqmp_state.pending | grlib_irqmp_state.force[0]) + grlib_irqmp_state.mask[0]; + + +level0 = pend ~grlib_irqmp_state.level; +level1 = pendgrlib_irqmp_state.level; + +DPRINTF(pend:0x%04x force:0x%04x mask:0x%04x lvl1:0x%04x lvl0:0x%04x\n, +grlib_irqmp_state.pending, grlib_irqmp_state.force[0], +grlib_irqmp_state.mask[0], level1, level0); + +/* Trigger level1 interrupt first and level0 if there is no level1 */ +if (level1 != 0) { +env-pil_in = level1; +} else { +env-pil_in = level0; +} + +if (env-pil_in (env-interrupt_index == 0 || +(env-interrupt_index ~15) == TT_EXTINT)) { +unsigned int i; + +for (i = 15; i 0; i--) { +if (env-pil_in (1 i)) { +int old_interrupt = env-interrupt_index; + +env-interrupt_index = TT_EXTINT | i; +if (old_interrupt != env-interrupt_index) { +DPRINTF(Set CPU IRQ %d\n, i); +cpu_interrupt(env, CPU_INTERRUPT_HARD); +} +break; +} +} +} else if
[Qemu-devel] [PATCH 1/2] Introduce strtosz_suffix()
From: Jes Sorensen jes.soren...@redhat.com This introduces strtosz_suffix() which allows the caller to specify a default suffix in case the non default of MB is wanted. strtosz() is kept as a wrapper for strtosz_suffix() which keeps it's current default of MB. Signed-off-by: Jes Sorensen jes.soren...@redhat.com --- cutils.c | 17 ++--- qemu-common.h |7 +++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/cutils.c b/cutils.c index 28089aa..1d24d9a 100644 --- a/cutils.c +++ b/cutils.c @@ -291,10 +291,10 @@ int fcntl_setfl(int fd, int flag) * value must be terminated by whitespace, ',' or '\0'. Return -1 on * error. */ -ssize_t strtosz(const char *nptr, char **end) +ssize_t strtosz_suffix(const char *nptr, char **end, const char default_suffix) { ssize_t retval = -1; -char *endptr, c; +char *endptr, c, d; int mul_required = 0; double val, mul, integral, fraction; @@ -313,10 +313,16 @@ ssize_t strtosz(const char *nptr, char **end) * part of a multi token argument. */ c = *endptr; +d = c; if (isspace(c) || c == '\0' || c == ',') { c = 0; +if (default_suffix) { +d = default_suffix; +} else { +d = c; +} } -switch (c) { +switch (d) { case 'B': case 'b': mul = 1; @@ -371,3 +377,8 @@ fail: return retval; } + +ssize_t strtosz(const char *nptr, char **end) +{ +return strtosz_suffix(nptr, end, 0); +} diff --git a/qemu-common.h b/qemu-common.h index de82c2e..dc44cd6 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -149,7 +149,14 @@ time_t mktimegm(struct tm *tm); int qemu_fls(int i); int qemu_fdatasync(int fd); int fcntl_setfl(int fd, int flag); + +#define STRTOSZ_DEFSUFFIX_TB 'T' +#define STRTOSZ_DEFSUFFIX_GB 'G' +#define STRTOSZ_DEFSUFFIX_MB 'M' +#define STRTOSZ_DEFSUFFIX_KB 'K' +#define STRTOSZ_DEFSUFFIX_B'B' ssize_t strtosz(const char *nptr, char **end); +ssize_t strtosz_suffix(const char *nptr, char **end, const char); /* path.c */ void init_paths(const char *prefix); -- 1.7.3.2
[Qemu-devel] [PATCH v4 0/2] Clean up img_create() and introduce strtosz_suffix()
From: Jes Sorensen jes.soren...@redhat.com This patch set introduces strtosz_suffix() which is needed to be able to use strtosz parsing with a non MB default suffix. This is used to clean up qemu-img.c:img_create(). Kevin asked me to rebase this instead of applying the other patches on top, so please discard the previous versions. Sorry for the patch noise. Jes Sorensen (2): Introduce strtosz_suffix() qemu-img.c: Clean up handling of image size in img_create() cutils.c | 17 ++--- qemu-common.h |7 +++ qemu-img.c| 23 +-- 3 files changed, 38 insertions(+), 9 deletions(-) -- 1.7.3.2
[Qemu-devel] [PATCH 2/2] qemu-img.c: Clean up handling of image size in img_create()
From: Jes Sorensen jes.soren...@redhat.com This cleans up the handling of image size in img_create() by parsing the value early, and then only setting it once if a value has been added as the last argument to the command line. Signed-off-by: Jes Sorensen jes.soren...@redhat.com --- qemu-img.c | 23 +-- 1 files changed, 17 insertions(+), 6 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index d146d8c..f078718 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -282,6 +282,7 @@ static int add_old_style_options(const char *fmt, QEMUOptionParameter *list, static int img_create(int argc, char **argv) { int c, ret = 0; +uint64_t img_size = -1; const char *fmt = raw; const char *base_fmt = NULL; const char *filename; @@ -329,6 +330,20 @@ static int img_create(int argc, char **argv) } filename = argv[optind++]; +/* Get image size, if specified */ +if (optind argc) { +ssize_t sval; +sval = strtosz_suffix(argv[optind++], NULL, STRTOSZ_DEFSUFFIX_B); +if (sval 0) { +error(Invalid image size specified! You may use k, M, G or + T suffixes for ); +error(kilobytes, megabytes, gigabytes and terabytes.); +ret = -1; +goto out; +} +img_size = (uint64_t)sval; +} + if (options !strcmp(options, ?)) { ret = print_block_option_help(filename, fmt); goto out; @@ -356,7 +371,8 @@ static int img_create(int argc, char **argv) /* Create parameter list with default values */ param = parse_option_parameters(, create_options, param); -set_option_parameter_int(param, BLOCK_OPT_SIZE, -1); + +set_option_parameter_int(param, BLOCK_OPT_SIZE, img_size); /* Parse -o options */ if (options) { @@ -368,11 +384,6 @@ static int img_create(int argc, char **argv) } } -/* Add size to parameters */ -if (optind argc) { -set_option_parameter(param, BLOCK_OPT_SIZE, argv[optind++]); -} - /* Add old-style options to parameters */ ret = add_old_style_options(fmt, param, base_filename, base_fmt); if (ret 0) { -- 1.7.3.2
[Qemu-devel] [PATCH 04/24] usb storage: use new descriptor infrastructure.
Switch the usb storage driver over to the new descriptor infrastructure. Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/usb-msd.c | 167 ++ 1 files changed, 63 insertions(+), 104 deletions(-) diff --git a/hw/usb-msd.c b/hw/usb-msd.c index 0a95d8d..20ab886 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -11,6 +11,7 @@ #include qemu-option.h #include qemu-config.h #include usb.h +#include usb-desc.h #include scsi.h #include console.h #include monitor.h @@ -72,69 +73,62 @@ struct usb_msd_csw { uint8_t status; }; -static const uint8_t qemu_msd_dev_descriptor[] = { - 0x12, /* u8 bLength; */ - 0x01, /* u8 bDescriptorType; Device */ - 0x00, 0x01, /* u16 bcdUSB; v1.0 */ - - 0x00, /* u8 bDeviceClass; */ - 0x00, /* u8 bDeviceSubClass; */ - 0x00, /* u8 bDeviceProtocol; [ low/full speeds only ] */ - 0x08, /* u8 bMaxPacketSize0; 8 Bytes */ - -/* Vendor and product id are arbitrary. */ - 0x00, 0x00, /* u16 idVendor; */ - 0x00, 0x00, /* u16 idProduct; */ - 0x00, 0x00, /* u16 bcdDevice */ - - 0x01, /* u8 iManufacturer; */ - 0x02, /* u8 iProduct; */ - 0x03, /* u8 iSerialNumber; */ - 0x01/* u8 bNumConfigurations; */ +enum { +STR_MANUFACTURER = 1, +STR_PRODUCT, +STR_SERIALNUMBER, }; -static const uint8_t qemu_msd_config_descriptor[] = { - - /* one configuration */ - 0x09, /* u8 bLength; */ - 0x02, /* u8 bDescriptorType; Configuration */ - 0x20, 0x00, /* u16 wTotalLength; */ - 0x01, /* u8 bNumInterfaces; (1) */ - 0x01, /* u8 bConfigurationValue; */ - 0x00, /* u8 iConfiguration; */ - 0xc0, /* u8 bmAttributes; -Bit 7: must be set, -6: Self-powered, -5: Remote wakeup, -4..0: resvd */ - 0x00, /* u8 MaxPower; */ - - /* one interface */ - 0x09, /* u8 if_bLength; */ - 0x04, /* u8 if_bDescriptorType; Interface */ - 0x00, /* u8 if_bInterfaceNumber; */ - 0x00, /* u8 if_bAlternateSetting; */ - 0x02, /* u8 if_bNumEndpoints; */ - 0x08, /* u8 if_bInterfaceClass; MASS STORAGE */ - 0x06, /* u8 if_bInterfaceSubClass; SCSI */ - 0x50, /* u8 if_bInterfaceProtocol; Bulk Only */ - 0x00, /* u8 if_iInterface; */ - - /* Bulk-In endpoint */ - 0x07, /* u8 ep_bLength; */ - 0x05, /* u8 ep_bDescriptorType; Endpoint */ - 0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */ - 0x02, /* u8 ep_bmAttributes; Bulk */ - 0x40, 0x00, /* u16 ep_wMaxPacketSize; */ - 0x00, /* u8 ep_bInterval; */ - - /* Bulk-Out endpoint */ - 0x07, /* u8 ep_bLength; */ - 0x05, /* u8 ep_bDescriptorType; Endpoint */ - 0x02, /* u8 ep_bEndpointAddress; OUT Endpoint 2 */ - 0x02, /* u8 ep_bmAttributes; Bulk */ - 0x40, 0x00, /* u16 ep_wMaxPacketSize; */ - 0x00/* u8 ep_bInterval; */ +static const USBDescStrings desc_strings = { +[STR_MANUFACTURER] = QEMU QEMU_VERSION, +[STR_PRODUCT] = QEMU USB HARDDRIVE, +[STR_SERIALNUMBER] = 1, +}; + +static const USBDescIface desc_iface0 = { +.bInterfaceNumber = 0, +.bNumEndpoints = 2, +.bInterfaceClass = USB_CLASS_MASS_STORAGE, +.bInterfaceSubClass= 0x06, /* SCSI */ +.bInterfaceProtocol= 0x50, /* Bulk */ +.eps = (USBDescEndpoint[]) { +{ +.bEndpointAddress = USB_DIR_IN | 0x01, +.bmAttributes = USB_ENDPOINT_XFER_BULK, +.wMaxPacketSize= 64, +},{ +.bEndpointAddress = USB_DIR_OUT | 0x02, +.bmAttributes = USB_ENDPOINT_XFER_BULK, +.wMaxPacketSize= 64, +}, +} +}; + +static const USBDescDevice desc_device = { +.bcdUSB= 0x0100, +.bMaxPacketSize0 = 8, +.bNumConfigurations= 1, +.confs = (USBDescConfig[]) { +{ +.bNumInterfaces= 1, +.bConfigurationValue = 1, +.bmAttributes = 0xc0, +.ifs = desc_iface0, +}, +}, +}; + +static const USBDesc desc = { +.id = { +.idVendor = 0, +.idProduct = 0, +.bcdDevice = 0, +.iManufacturer = STR_MANUFACTURER, +.iProduct = STR_PRODUCT, +.iSerialNumber = STR_SERIALNUMBER, +}, +.full = desc_device, +.str = desc_strings, }; static
[Qemu-devel] Re: [PATCH 2/3] block: Introduce path_has_protocol() function
Am 30.11.2010 16:14, schrieb Stefan Hajnoczi: The bdrv_find_protocol() function returns NULL if an unknown protocol name is given. It returns the file protocol when the filename contains no protocol at all. This makes it difficult to distinguish between paths which contain a protocol and those which do not. Factor out a helper function that tests whether or not a filename has a protocol. The next patch makes use of this function. Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com This breaks the mingw32 build: /home/kwolf/tmp/win32/qemu/block.c: In function 'path_has_protocol': /home/kwolf/tmp/win32/qemu/block.c:78: warning: implicit declaration of function 'is_windows_drive_prefix' /home/kwolf/tmp/win32/qemu/block.c:78: warning: nested extern declaration of 'is_windows_drive_prefix' /home/kwolf/tmp/win32/qemu/block.c: At top level: /home/kwolf/tmp/win32/qemu/block.c:261: error: static declaration of 'is_windows_drive_prefix' follows non-static declaration /home/kwolf/tmp/win32/qemu/block.c:78: note: previous implicit declaration of 'is_windows_drive_prefix' was here Kevin
[Qemu-devel] [PATCH 01/24] usb: data structs and helpers for usb descriptors.
This patch adds hw/usb-desc.[ch] files. They carry data structures for various usb descriptors and helper functions to generate usb packets from the structures. The intention is to have a internal representation of the device desription which is more usable than the current char array blobs, so we can have common code handle common usb device emulation using the device description. The usage of this infrastructure is optional for usb drivers as there are cases such as pass-through where it probably isn't very useful. Signed-off-by: Gerd Hoffmann kra...@redhat.com --- Makefile.objs |2 +- hw/usb-desc.c | 238 + hw/usb-desc.h | 86 + hw/usb.h |9 ++ trace-events |5 + 5 files changed, 339 insertions(+), 1 deletions(-) create mode 100644 hw/usb-desc.c create mode 100644 hw/usb-desc.h diff --git a/Makefile.objs b/Makefile.objs index 04625eb..39b1aea 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -85,7 +85,7 @@ common-obj-y += eeprom93xx.o common-obj-y += scsi-disk.o cdrom.o common-obj-y += scsi-generic.o scsi-bus.o common-obj-y += usb.o usb-hub.o usb-$(HOST_USB).o usb-hid.o usb-msd.o usb-wacom.o -common-obj-y += usb-serial.o usb-net.o usb-bus.o +common-obj-y += usb-serial.o usb-net.o usb-bus.o usb-desc.o common-obj-$(CONFIG_SSI) += ssi.o common-obj-$(CONFIG_SSI_SD) += ssi-sd.o common-obj-$(CONFIG_SD) += sd.o diff --git a/hw/usb-desc.c b/hw/usb-desc.c new file mode 100644 index 000..559ced7 --- /dev/null +++ b/hw/usb-desc.c @@ -0,0 +1,238 @@ +#include usb.h +#include usb-desc.h +#include trace.h + +/* -- */ + +static uint8_t usb_lo(uint16_t val) +{ +return val 0xff; +} + +static uint8_t usb_hi(uint16_t val) +{ +return (val 8) 0xff; +} + +int usb_desc_device(const USBDescID *id, const USBDescDevice *dev, +uint8_t *dest, size_t len) +{ +uint8_t bLength = 0x12; + +if (len bLength) { +return -1; +} + +dest[0x00] = bLength; +dest[0x01] = USB_DT_DEVICE; + +dest[0x02] = usb_lo(dev-bcdUSB); +dest[0x03] = usb_hi(dev-bcdUSB); +dest[0x04] = dev-bDeviceClass; +dest[0x05] = dev-bDeviceSubClass; +dest[0x06] = dev-bDeviceProtocol; +dest[0x07] = dev-bMaxPacketSize0; + +dest[0x08] = usb_lo(id-idVendor); +dest[0x09] = usb_hi(id-idVendor); +dest[0x0a] = usb_lo(id-idProduct); +dest[0x0b] = usb_hi(id-idProduct); +dest[0x0c] = usb_lo(id-bcdDevice); +dest[0x0d] = usb_hi(id-bcdDevice); +dest[0x0e] = id-iManufacturer; +dest[0x0f] = id-iProduct; +dest[0x10] = id-iSerialNumber; + +dest[0x11] = dev-bNumConfigurations; + +return bLength; +} + +int usb_desc_config(const USBDescConfig *conf, uint8_t *dest, size_t len) +{ +uint8_t bLength = 0x09; +uint16_t wTotalLength = 0; +int i, rc, count; + +if (len bLength) { +return -1; +} + +dest[0x00] = bLength; +dest[0x01] = USB_DT_CONFIG; +dest[0x04] = conf-bNumInterfaces; +dest[0x05] = conf-bConfigurationValue; +dest[0x06] = conf-iConfiguration; +dest[0x07] = conf-bmAttributes; +dest[0x08] = conf-bMaxPower; +wTotalLength += bLength; + +count = conf-nif ? conf-nif : conf-bNumInterfaces; +for (i = 0; i count; i++) { +rc = usb_desc_iface(conf-ifs + i, dest + wTotalLength, len - wTotalLength); +if (rc 0) { +return rc; +} +wTotalLength += rc; +} + +dest[0x02] = usb_lo(wTotalLength); +dest[0x03] = usb_hi(wTotalLength); +return wTotalLength; +} + +int usb_desc_iface(const USBDescIface *iface, uint8_t *dest, size_t len) +{ +uint8_t bLength = 0x09; +int i, rc, pos = 0; + +if (len bLength) { +return -1; +} + +dest[0x00] = bLength; +dest[0x01] = USB_DT_INTERFACE; +dest[0x02] = iface-bInterfaceNumber; +dest[0x03] = iface-bAlternateSetting; +dest[0x04] = iface-bNumEndpoints; +dest[0x05] = iface-bInterfaceClass; +dest[0x06] = iface-bInterfaceSubClass; +dest[0x07] = iface-bInterfaceProtocol; +dest[0x08] = iface-iInterface; +pos += bLength; + +for (i = 0; i iface-ndesc; i++) { +rc = usb_desc_other(iface-descs + i, dest + pos, len - pos); +if (rc 0) { +return rc; +} +pos += rc; +} + +for (i = 0; i iface-bNumEndpoints; i++) { +rc = usb_desc_endpoint(iface-eps + i, dest + pos, len - pos); +if (rc 0) { +return rc; +} +pos += rc; +} + +return pos; +} + +int usb_desc_endpoint(const USBDescEndpoint *ep, uint8_t *dest, size_t len) +{ +uint8_t bLength = 0x07; + +if (len bLength) { +return -1; +} + +dest[0x00] = bLength; +dest[0x01] = USB_DT_ENDPOINT; +dest[0x02] = ep-bEndpointAddress; +dest[0x03] = ep-bmAttributes; +dest[0x04] = usb_lo(ep-wMaxPacketSize); +dest[0x05] =
[Qemu-devel] [PATCH 02/24] usb hid: use new descriptor infrastructure.
Switch the usb hid drivers (keyboard, mouse, tablet) over to the new descriptor infrastructure. Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/usb-hid.c | 448 +++--- 1 files changed, 205 insertions(+), 243 deletions(-) diff --git a/hw/usb-hid.c b/hw/usb-hid.c index 882d933..74d17fc 100644 --- a/hw/usb-hid.c +++ b/hw/usb-hid.c @@ -25,6 +25,7 @@ #include hw.h #include console.h #include usb.h +#include usb-desc.h #include sysemu.h /* HID interface requests */ @@ -73,190 +74,206 @@ typedef struct USBHIDState { void (*datain)(void *); } USBHIDState; -/* mostly the same values as the Bochs USB Mouse device */ -static const uint8_t qemu_mouse_dev_descriptor[] = { - 0x12, /* u8 bLength; */ - 0x01, /* u8 bDescriptorType; Device */ - 0x00, 0x01, /* u16 bcdUSB; v1.0 */ - - 0x00, /* u8 bDeviceClass; */ - 0x00, /* u8 bDeviceSubClass; */ - 0x00, /* u8 bDeviceProtocol; [ low/full speeds only ] */ - 0x08, /* u8 bMaxPacketSize0; 8 Bytes */ - - 0x27, 0x06, /* u16 idVendor; */ - 0x01, 0x00, /* u16 idProduct; */ - 0x00, 0x00, /* u16 bcdDevice */ - - 0x03, /* u8 iManufacturer; */ - 0x02, /* u8 iProduct; */ - 0x01, /* u8 iSerialNumber; */ - 0x01/* u8 bNumConfigurations; */ +enum { +STR_MANUFACTURER = 1, +STR_PRODUCT_MOUSE, +STR_PRODUCT_TABLET, +STR_PRODUCT_KEYBOARD, +STR_SERIALNUMBER, +STR_CONFIG_MOUSE, +STR_CONFIG_TABLET, +STR_CONFIG_KEYBOARD, }; -static const uint8_t qemu_mouse_config_descriptor[] = { - /* one configuration */ - 0x09, /* u8 bLength; */ - 0x02, /* u8 bDescriptorType; Configuration */ - 0x22, 0x00, /* u16 wTotalLength; */ - 0x01, /* u8 bNumInterfaces; (1) */ - 0x01, /* u8 bConfigurationValue; */ - 0x04, /* u8 iConfiguration; */ - 0xe0, /* u8 bmAttributes; -Bit 7: must be set, -6: Self-powered, -5: Remote wakeup, -4..0: resvd */ - 50, /* u8 MaxPower; */ - - /* USB 1.1: -* USB 2.0, single TT organization (mandatory): -* one interface, protocol 0 -* -* USB 2.0, multiple TT organization (optional): -* two interfaces, protocols 1 (like single TT) -* and 2 (multiple TT mode) ... config is -* sometimes settable -* NOT IMPLEMENTED -*/ - - /* one interface */ - 0x09, /* u8 if_bLength; */ - 0x04, /* u8 if_bDescriptorType; Interface */ - 0x00, /* u8 if_bInterfaceNumber; */ - 0x00, /* u8 if_bAlternateSetting; */ - 0x01, /* u8 if_bNumEndpoints; */ - 0x03, /* u8 if_bInterfaceClass; */ - 0x01, /* u8 if_bInterfaceSubClass; */ - 0x02, /* u8 if_bInterfaceProtocol; [usb1.1 or single tt] */ - 0x07, /* u8 if_iInterface; */ - -/* HID descriptor */ -0x09,/* u8 bLength; */ -0x21,/* u8 bDescriptorType; */ -0x01, 0x00, /* u16 HID_class */ -0x00,/* u8 country_code */ -0x01,/* u8 num_descriptors */ -0x22,/* u8 type; Report */ -52, 0, /* u16 len */ - - /* one endpoint (status change endpoint) */ - 0x07, /* u8 ep_bLength; */ - 0x05, /* u8 ep_bDescriptorType; Endpoint */ - 0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */ - 0x03, /* u8 ep_bmAttributes; Interrupt */ - 0x04, 0x00, /* u16 ep_wMaxPacketSize; */ - 0x0a, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */ +static const USBDescStrings desc_strings = { +[STR_MANUFACTURER] = QEMU QEMU_VERSION, +[STR_PRODUCT_MOUSE]= QEMU USB Mouse, +[STR_PRODUCT_TABLET] = QEMU USB Tablet, +[STR_PRODUCT_KEYBOARD] = QEMU USB Keyboard, +[STR_SERIALNUMBER] = 1, +[STR_CONFIG_MOUSE] = HID Mouse, +[STR_CONFIG_TABLET]= HID Tablet, +[STR_CONFIG_KEYBOARD] = HID Keyboard, }; -static const uint8_t qemu_tablet_config_descriptor[] = { - /* one configuration */ - 0x09, /* u8 bLength; */ - 0x02, /* u8 bDescriptorType; Configuration */ - 0x22, 0x00, /* u16 wTotalLength; */ - 0x01, /* u8 bNumInterfaces; (1) */ - 0x01, /* u8 bConfigurationValue; */ - 0x05, /* u8 iConfiguration; */ - 0xa0, /* u8 bmAttributes; -Bit 7: must be set, -6: Self-powered, -5: Remote wakeup, -4..0: resvd
Re: [Qemu-devel] [PATCH 2/6] [RFC] Emulation of GRLIB IRQMP as defined in GRLIB IP Core User's Manual.
On 12/09/2010 11:32 AM, Edgar E. Iglesias wrote: On Mon, Dec 06, 2010 at 10:26:03AM +0100, Fabien Chouteau wrote: Signed-off-by: Fabien Chouteauchout...@adacore.com --- hw/grlib_irqmp.c | 416 ++ 1 files changed, 416 insertions(+), 0 deletions(-) diff --git a/hw/grlib_irqmp.c b/hw/grlib_irqmp.c new file mode 100644 index 000..69e1553 --- /dev/null +++ b/hw/grlib_irqmp.c @@ -0,0 +1,416 @@ +/* + * QEMU GRLIB IRQMP Emulator + * + * (Multiprocessor and extended interrupt not supported) + * + * Copyright (c) 2010 AdaCore + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the Software), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include sysbus.h +#include cpu.h + +#include grlib.h + +/* #define DEBUG_IRQ */ + +#ifdef DEBUG_IRQ +#define DPRINTF(fmt, ...) \ +do { printf(IRQMP: fmt , ## __VA_ARGS__); } while (0) +#else +#define DPRINTF(fmt, ...) +#endif + +#define IRQMP_MAX_CPU 16 +#define IRQMP_REG_SIZE 256 /* Size of memory mapped registers */ + +/* Memory mapped register offsets */ +#define LEVEL_OFFSET 0x00 +#define PENDING_OFFSET 0x04 +#define FORCE0_OFFSET0x08 +#define CLEAR_OFFSET 0x0C +#define MP_STATUS_OFFSET 0x10 +#define BROADCAST_OFFSET 0x14 +#define MASK_OFFSET 0x40 +#define FORCE_OFFSET 0x80 +#define EXTENDED_OFFSET 0xC0 + +typedef struct IRQMP +{ +SysBusDevice busdev; + +CPUSPARCState *env; +} IRQMP; + +typedef struct IRQMPState +{ +uint32_t level; +uint32_t pending; +uint32_t clear; +uint32_t broadcast; + +uint32_t mask[IRQMP_MAX_CPU]; +uint32_t force[IRQMP_MAX_CPU]; +uint32_t extended[IRQMP_MAX_CPU]; + +IRQMP*parent; +} IRQMPState; + +IRQMPState grlib_irqmp_state; + +void grlib_irqmp_set_irq(void *opaque, int irq, int level); + +DeviceState *grlib_irqmp_create(target_phys_addr_t base, +CPUState*env, +qemu_irq **cpu_irqs, +uint32_t nr_irqs) +{ +DeviceState *dev; + +assert(cpu_irqs != NULL); + +dev = qdev_create(NULL, grlib,irqmp); +qdev_prop_set_ptr(dev, cpustate, env); + +if (qdev_init(dev)) { +return NULL; +} + +sysbus_mmio_map(sysbus_from_qdev(dev), 0, base); + +*cpu_irqs = qemu_allocate_irqs(grlib_irqmp_set_irq, +grlib_irqmp_state, + nr_irqs); + +return dev; +} + +static void grlib_irqmp_check_irqs(CPUState *env) +{ +uint32_t pend = 0; +uint32_t level0 = 0; +uint32_t level1 = 0; + +assert(env != NULL); + +/* IRQ for CPU 0 (no SMP support) */ +pend = (grlib_irqmp_state.pending | grlib_irqmp_state.force[0]) + grlib_irqmp_state.mask[0]; + + +level0 = pend ~grlib_irqmp_state.level; +level1 = pend grlib_irqmp_state.level; + +DPRINTF(pend:0x%04x force:0x%04x mask:0x%04x lvl1:0x%04x lvl0:0x%04x\n, +grlib_irqmp_state.pending, grlib_irqmp_state.force[0], +grlib_irqmp_state.mask[0], level1, level0); + +/* Trigger level1 interrupt first and level0 if there is no level1 */ +if (level1 != 0) { +env-pil_in = level1; +} else { +env-pil_in = level0; +} + +if (env-pil_in (env-interrupt_index == 0 || +(env-interrupt_index ~15) == TT_EXTINT)) { +unsigned int i; + +for (i = 15; i 0; i--) { +if (env-pil_in (1 i)) { +int old_interrupt = env-interrupt_index; + +env-interrupt_index = TT_EXTINT | i; +if (old_interrupt != env-interrupt_index) { +DPRINTF(Set CPU IRQ %d\n, i); +cpu_interrupt(env, CPU_INTERRUPT_HARD); +} +break; +} +} +} else if (!env-pil_in (env-interrupt_index ~15) == TT_EXTINT) { +DPRINTF(Reset CPU IRQ %d\n, env-interrupt_index 15); +
[Qemu-devel] [PATCH 05/24] usb wacom: use new descriptor infrastructure.
Switch the usb wavom driver over to the new descriptor infrastructure. Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/usb-wacom.c | 178 +++- 1 files changed, 73 insertions(+), 105 deletions(-) diff --git a/hw/usb-wacom.c b/hw/usb-wacom.c index 47f26cd..ffe6ac7 100644 --- a/hw/usb-wacom.c +++ b/hw/usb-wacom.c @@ -28,6 +28,7 @@ #include hw.h #include console.h #include usb.h +#include usb-desc.h /* Interface requests */ #define WACOM_GET_REPORT 0x2101 @@ -54,68 +55,75 @@ typedef struct USBWacomState { int changed; } USBWacomState; -static const uint8_t qemu_wacom_dev_descriptor[] = { -0x12, /* u8 bLength; */ -0x01, /* u8 bDescriptorType; Device */ -0x10, 0x10,/* u16 bcdUSB; v1.10 */ +enum { +STR_MANUFACTURER = 1, +STR_PRODUCT, +STR_SERIALNUMBER, +}; -0x00, /* u8 bDeviceClass; */ -0x00, /* u8 bDeviceSubClass; */ -0x00, /* u8 bDeviceProtocol; [ low/full speeds only ] */ -0x08, /* u8 bMaxPacketSize0; 8 Bytes */ +static const USBDescStrings desc_strings = { +[STR_MANUFACTURER] = QEMU QEMU_VERSION, +[STR_PRODUCT] = Wacom PenPartner, +[STR_SERIALNUMBER] = 1, +}; -0x6a, 0x05,/* u16 idVendor; */ -0x00, 0x00,/* u16 idProduct; */ -0x10, 0x42,/* u16 bcdDevice */ +static const USBDescIface desc_iface_wacom = { +.bInterfaceNumber = 0, +.bNumEndpoints = 1, +.bInterfaceClass = USB_CLASS_HID, +.bInterfaceSubClass= 0x01, /* boot */ +.bInterfaceProtocol= 0x02, +.ndesc = 1, +.descs = (USBDescOther[]) { +{ +/* HID descriptor */ +.data = (uint8_t[]) { +0x09, /* u8 bLength */ +0x21, /* u8 bDescriptorType */ +0x01, 0x10,/* u16 HID_class */ +0x00, /* u8 country_code */ +0x01, /* u8 num_descriptors */ +0x22, /* u8 type: Report */ +0x6e, 0, /* u16 len */ +}, +}, +}, +.eps = (USBDescEndpoint[]) { +{ +.bEndpointAddress = USB_DIR_IN | 0x01, +.bmAttributes = USB_ENDPOINT_XFER_INT, +.wMaxPacketSize= 8, +.bInterval = 0x0a, +}, +}, +}; -0x01, /* u8 iManufacturer; */ -0x02, /* u8 iProduct; */ -0x00, /* u8 iSerialNumber; */ -0x01, /* u8 bNumConfigurations; */ +static const USBDescDevice desc_device_wacom = { +.bcdUSB= 0x0110, +.bMaxPacketSize0 = 8, +.bNumConfigurations= 1, +.confs = (USBDescConfig[]) { +{ +.bNumInterfaces= 1, +.bConfigurationValue = 1, +.bmAttributes = 0x80, +.bMaxPower = 40, +.ifs = desc_iface_wacom, +}, +}, }; -static const uint8_t qemu_wacom_config_descriptor[] = { -/* one configuration */ -0x09, /* u8 bLength; */ -0x02, /* u8 bDescriptorType; Configuration */ -0x22, 0x00,/* u16 wTotalLength; */ -0x01, /* u8 bNumInterfaces; (1) */ -0x01, /* u8 bConfigurationValue; */ -0x00, /* u8 iConfiguration; */ -0x80, /* u8 bmAttributes; -Bit 7: must be set, -6: Self-powered, -5: Remote wakeup, -4..0: resvd */ -40,/* u8 MaxPower; */ - -/* one interface */ -0x09, /* u8 if_bLength; */ -0x04, /* u8 if_bDescriptorType; Interface */ -0x00, /* u8 if_bInterfaceNumber; */ -0x00, /* u8 if_bAlternateSetting; */ -0x01, /* u8 if_bNumEndpoints; */ -0x03, /* u8 if_bInterfaceClass; HID */ -0x01, /* u8 if_bInterfaceSubClass; Boot */ -0x02, /* u8 if_bInterfaceProtocol; [usb1.1 or single tt] */ -0x00, /* u8 if_iInterface; */ - -/* HID descriptor */ -0x09, /* u8 bLength; */ -0x21, /* u8 bDescriptorType; */ -0x01, 0x10,/* u16 HID_class */ -0x00, /* u8 country_code */ -0x01, /* u8 num_descriptors */ -0x22, /* u8 type; Report */ -0x6e, 0x00,/* u16 len */ - -/* one endpoint (status change endpoint) */ -0x07, /* u8 ep_bLength; */ -0x05, /* u8 ep_bDescriptorType; Endpoint */ -0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */ -0x03, /* u8 ep_bmAttributes; Interrupt */ -0x08, 0x00,/* u16 ep_wMaxPacketSize; */ -0x0a, /* u8 ep_bInterval; */ +static
[Qemu-devel] [PATCH 09/24] usb storage: serial number support
If a serial number is present for the drive fill it into the usb serialnumber string descriptor. Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/usb-msd.c |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/hw/usb-msd.c b/hw/usb-msd.c index 20ab886..9aa 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -482,6 +482,7 @@ static int usb_msd_initfn(USBDevice *dev) { MSDState *s = DO_UPCAST(MSDState, dev, dev); BlockDriverState *bs = s-conf.bs; +DriveInfo *dinfo; if (!bs) { error_report(usb-msd: drive property not set); @@ -500,6 +501,11 @@ static int usb_msd_initfn(USBDevice *dev) bdrv_detach(bs, s-dev.qdev); s-conf.bs = NULL; +dinfo = drive_get_by_blockdev(bs); +if (dinfo dinfo-serial) { +usb_desc_set_string(dev, STR_SERIALNUMBER, dinfo-serial); +} + s-dev.speed = USB_SPEED_FULL; scsi_bus_new(s-bus, s-dev.qdev, 0, 1, usb_msd_command_complete); s-scsi_dev = scsi_bus_legacy_add_drive(s-bus, bs, 0); -- 1.7.1
[Qemu-devel] [PATCH 06/14] Fix formatting and missing braces in qemu-img.c
From: Jes Sorensen jes.soren...@redhat.com Signed-off-by: Jes Sorensen jes.soren...@redhat.com Reviewed-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com Signed-off-by: Kevin Wolf kw...@redhat.com --- qemu-img.c | 77 +++ 1 files changed, 51 insertions(+), 26 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 50cfdda..cc77048 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -305,8 +305,9 @@ static int img_create(int argc, char **argv) flags = 0; for(;;) { c = getopt(argc, argv, F:b:f:he6o:); -if (c == -1) +if (c == -1) { break; +} switch(c) { case 'h': help(); @@ -333,8 +334,9 @@ static int img_create(int argc, char **argv) } /* Get the filename */ -if (optind = argc) +if (optind = argc) { help(); +} filename = argv[optind++]; if (options !strcmp(options, ?)) { @@ -471,8 +473,9 @@ static int img_check(int argc, char **argv) fmt = NULL; for(;;) { c = getopt(argc, argv, f:h); -if (c == -1) +if (c == -1) { break; +} switch(c) { case 'h': help(); @@ -482,8 +485,9 @@ static int img_check(int argc, char **argv) break; } } -if (optind = argc) +if (optind = argc) { help(); +} filename = argv[optind++]; bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS); @@ -547,8 +551,9 @@ static int img_commit(int argc, char **argv) fmt = NULL; for(;;) { c = getopt(argc, argv, f:h); -if (c == -1) +if (c == -1) { break; +} switch(c) { case 'h': help(); @@ -558,8 +563,9 @@ static int img_commit(int argc, char **argv) break; } } -if (optind = argc) +if (optind = argc) { help(); +} filename = argv[optind++]; bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_RDWR); @@ -683,8 +689,9 @@ static int img_convert(int argc, char **argv) flags = 0; for(;;) { c = getopt(argc, argv, f:O:B:s:hce6o:); -if (c == -1) +if (c == -1) { break; +} switch(c) { case 'h': help(); @@ -717,7 +724,9 @@ static int img_convert(int argc, char **argv) } bs_n = argc - optind - 1; -if (bs_n 1) help(); +if (bs_n 1) { +help(); +} out_filename = argv[argc - 1]; @@ -905,8 +914,9 @@ static int img_convert(int argc, char **argv) } assert (remainder == 0); -if (n cluster_sectors) +if (n cluster_sectors) { memset(buf + n * 512, 0, cluster_size - n * 512); +} if (is_not_zero(buf, cluster_size)) { ret = bdrv_write_compressed(out_bs, sector_num, buf, cluster_sectors); @@ -926,12 +936,14 @@ static int img_convert(int argc, char **argv) sector_num = 0; // total number of sectors converted so far for(;;) { nb_sectors = total_sectors - sector_num; -if (nb_sectors = 0) +if (nb_sectors = 0) { break; -if (nb_sectors = (IO_BUF_SIZE / 512)) +} +if (nb_sectors = (IO_BUF_SIZE / 512)) { n = (IO_BUF_SIZE / 512); -else +} else { n = nb_sectors; +} while (sector_num - bs_offset = bs_sectors) { bs_i ++; @@ -943,8 +955,9 @@ static int img_convert(int argc, char **argv) sector_num, bs_i, bs_offset, bs_sectors); */ } -if (n bs_offset + bs_sectors - sector_num) +if (n bs_offset + bs_sectors - sector_num) { n = bs_offset + bs_sectors - sector_num; +} if (has_zero_init) { /* If the output image is being created as a copy on write image, @@ -1080,8 +1093,9 @@ static int img_info(int argc, char **argv) fmt = NULL; for(;;) { c = getopt(argc, argv, f:h); -if (c == -1) +if (c == -1) { break; +} switch(c) { case 'h': help(); @@ -1091,8 +1105,9 @@ static int img_info(int argc, char **argv) break; } } -if (optind = argc) +if (optind = argc) { help(); +} filename = argv[optind++]; bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_NO_BACKING); @@ -1103,11 +1118,12 @@ static int img_info(int argc, char **argv) bdrv_get_geometry(bs, total_sectors); get_human_readable_size(size_buf, sizeof(size_buf), total_sectors * 512); allocated_size = get_allocated_file_size(filename); -if (allocated_size 0) +if (allocated_size 0) {
[Qemu-devel] Re: [PATCH 03/13] ide: Split out BMDMA code from ATA core
Am 08.12.2010 13:13, schrieb Alexander Graf: The ATA core is currently heavily intertwined with BMDMA code. Let's loosen that a bit, so we can happily replace the DMA backend with different implementations. Signed-off-by: Alexander Graf ag...@suse.de --- v7 - v8: - rewrite as DMA ops --- hw/ide/cmd646.c |6 +- hw/ide/core.c | 322 - hw/ide/internal.h | 53 +++-- hw/ide/pci.c | 278 +- hw/ide/pci.h |1 + hw/ide/piix.c |6 +- hw/ide/via.c |6 +- 7 files changed, 399 insertions(+), 273 deletions(-) @@ -367,6 +369,17 @@ typedef enum { IDE_HD, IDE_CD, IDE_CFATA } IDEDriveKind; typedef void EndTransferFunc(IDEState *); + +typedef void TransferStartFunc(IDEState *, + uint8_t *, + int, + EndTransferFunc *); +typedef void IRQSetFunc(IDEBus *); These two typedefs are unused. +typedef void DMAStartFunc(void *, IDEState *, BlockDriverCompletionFunc *); +typedef int DMAFunc(void *); +typedef int DMAIntFunc(void *, int); +typedef void DMARestartFunc(void *, int, int); + /* NOTE: IDEState represents in fact one drive */ struct IDEState { IDEBus *bus; @@ -443,12 +456,33 @@ struct IDEState { uint8_t *smart_selftest_data; }; +struct IDEDMAOps { +DMAFunc *start_irq; +DMAStartFunc *start_dma; +DMAFunc *start_transfer; +DMAIntFunc *prepare_buf; +DMAIntFunc *rw_buf; +DMAIntFunc *set_unit; +DMAIntFunc *set_status; +DMAFunc *set_inactive; +DMARestartFunc *restart_cb; +DMAFunc *reset; +}; + +struct IDEDMA { +struct IDEDMAOps const *ops; Why hiding the const somewhere in the middle? +void *opaque; +struct iovec iov; +QEMUIOVector qiov; +BlockDriverAIOCB *aiocb; +}; I'm wondering if this interface where you pass a void* to all DMA functions is really optimal. You completely lose type safety this way. Maybe we should use inheritance like in other places in qemu and implement BMDMAState with IDEDMA as its base class? This would mean that we need to make IDEBus.dma a pointer rather than embedding the structure, but it's probably worth the changes. +static int bmdma_set_status(void *opaque, int status) +{ +BMDMAState *bm = opaque; +bm-status |= status; The name of this function is misleading. You're just setting a flag, not setting a new value for the whole status register. Kevin
[Qemu-devel] [PATCH 07/24] usb hub: use new descriptor infrastructure.
Switch the usb hub driver over to the new descriptor infrastructure. It also removes the nr_ports variable and MAX_PORTS define and introduces a NUM_PORTS define instead. The numver of ports was (and still is) fixed at 8 anyway. Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/usb-hub.c | 141 -- 1 files changed, 78 insertions(+), 63 deletions(-) diff --git a/hw/usb-hub.c b/hw/usb-hub.c index 2a1edfc..0f8d060 100644 --- a/hw/usb-hub.c +++ b/hw/usb-hub.c @@ -23,10 +23,11 @@ */ #include qemu-common.h #include usb.h +#include usb-desc.h //#define DEBUG -#define MAX_PORTS 8 +#define NUM_PORTS 8 typedef struct USBHubPort { USBPort port; @@ -36,8 +37,7 @@ typedef struct USBHubPort { typedef struct USBHubState { USBDevice dev; -int nb_ports; -USBHubPort ports[MAX_PORTS]; +USBHubPort ports[NUM_PORTS]; } USBHubState; #define ClearHubFeature(0x2000 | USB_REQ_CLEAR_FEATURE) @@ -83,6 +83,60 @@ typedef struct USBHubState { /* same as Linux kernel root hubs */ +enum { +STR_MANUFACTURER = 1, +STR_PRODUCT, +STR_SERIALNUMBER, +}; + +static const USBDescStrings desc_strings = { +[STR_MANUFACTURER] = QEMU QEMU_VERSION, +[STR_PRODUCT] = QEMU USB Hub, +[STR_SERIALNUMBER] = 314159, +}; + +static const USBDescIface desc_iface_hub = { +.bInterfaceNumber = 0, +.bNumEndpoints = 1, +.bInterfaceClass = USB_CLASS_HUB, +.eps = (USBDescEndpoint[]) { +{ +.bEndpointAddress = USB_DIR_IN | 0x01, +.bmAttributes = USB_ENDPOINT_XFER_INT, +.wMaxPacketSize= 1 + (NUM_PORTS + 7) / 8, +.bInterval = 0xff, +}, +} +}; + +static const USBDescDevice desc_device_hub = { +.bcdUSB= 0x0110, +.bDeviceClass = USB_CLASS_HUB, +.bMaxPacketSize0 = 8, +.bNumConfigurations= 1, +.confs = (USBDescConfig[]) { +{ +.bNumInterfaces= 1, +.bConfigurationValue = 1, +.bmAttributes = 0xe0, +.ifs = desc_iface_hub, +}, +}, +}; + +static const USBDesc desc_hub = { +.id = { +.idVendor = 0, +.idProduct = 0, +.bcdDevice = 0x0101, +.iManufacturer = STR_MANUFACTURER, +.iProduct = STR_PRODUCT, +.iSerialNumber = STR_SERIALNUMBER, +}, +.full = desc_device_hub, +.str = desc_strings, +}; + static const uint8_t qemu_hub_dev_descriptor[] = { 0x12, /* u8 bLength; */ 0x01, /* u8 bDescriptorType; Device */ @@ -209,6 +263,11 @@ static int usb_hub_handle_control(USBDevice *dev, int request, int value, USBHubState *s = (USBHubState *)dev; int ret; +ret = usb_desc_handle_control(dev, request, value, index, length, data); +if (ret = 0) { +return ret; +} + switch(request) { case DeviceRequest | USB_REQ_GET_STATUS: data[0] = (1 USB_DEVICE_SELF_POWERED) | @@ -242,53 +301,6 @@ static int usb_hub_handle_control(USBDevice *dev, int request, int value, dev-addr = value; ret = 0; break; -case DeviceRequest | USB_REQ_GET_DESCRIPTOR: -switch(value 8) { -case USB_DT_DEVICE: -memcpy(data, qemu_hub_dev_descriptor, - sizeof(qemu_hub_dev_descriptor)); -ret = sizeof(qemu_hub_dev_descriptor); -break; -case USB_DT_CONFIG: -memcpy(data, qemu_hub_config_descriptor, - sizeof(qemu_hub_config_descriptor)); - -/* status change endpoint size based on number - * of ports */ -data[22] = (s-nb_ports + 1 + 7) / 8; - -ret = sizeof(qemu_hub_config_descriptor); -break; -case USB_DT_STRING: -switch(value 0xff) { -case 0: -/* language ids */ -data[0] = 4; -data[1] = 3; -data[2] = 0x09; -data[3] = 0x04; -ret = 4; -break; -case 1: -/* serial number */ -ret = set_usb_string(data, 314159); -break; -case 2: -/* product description */ -ret = set_usb_string(data, QEMU USB Hub); -break; -case 3: -/* vendor description */ -ret = set_usb_string(data, QEMU QEMU_VERSION); -break; -default: -goto fail; -} -break; -default: -goto fail; -} -break; case DeviceRequest | USB_REQ_GET_CONFIGURATION: data[0] = 1; ret = 1; @@ -315,8 +327,9 @@ static int
[Qemu-devel] [PATCH 20/24] usb: add attach callback
Add handle_attach() callback to USBDeviceInfo which is called by the generic package handler when the device is attached to the usb bus (i.e. plugged into a port). Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/usb.c |7 ++- hw/usb.h |5 + 2 files changed, 11 insertions(+), 1 deletions(-) diff --git a/hw/usb.c b/hw/usb.c index ba720b4..82a6217 100644 --- a/hw/usb.c +++ b/hw/usb.c @@ -194,6 +194,9 @@ int usb_generic_handle_packet(USBDevice *s, USBPacket *p) switch(p-pid) { case USB_MSG_ATTACH: s-state = USB_STATE_ATTACHED; +if (s-info-handle_attach) { +s-info-handle_attach(s); +} return 0; case USB_MSG_DETACH: @@ -204,7 +207,9 @@ int usb_generic_handle_packet(USBDevice *s, USBPacket *p) s-remote_wakeup = 0; s-addr = 0; s-state = USB_STATE_DEFAULT; -s-info-handle_reset(s); +if (s-info-handle_reset) { +s-info-handle_reset(s); +} return 0; } diff --git a/hw/usb.h b/hw/usb.h index 864501a..0219816 100644 --- a/hw/usb.h +++ b/hw/usb.h @@ -194,6 +194,11 @@ struct USBDeviceInfo { void (*handle_destroy)(USBDevice *dev); /* + * Attach the device + */ +void (*handle_attach)(USBDevice *dev); + +/* * Reset the device */ void (*handle_reset)(USBDevice *dev); -- 1.7.1
[Qemu-devel] [PATCH 18/24] usb: hid: remote wakeup support.
Add usb_wakeup() call to the hid driver so remote wakeup actually works. Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/usb-hid.c |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/hw/usb-hid.c b/hw/usb-hid.c index 1c35960..60fa57f 100644 --- a/hw/usb-hid.c +++ b/hw/usb-hid.c @@ -429,6 +429,8 @@ static void usb_hid_changed(USBHIDState *hs) if (hs-datain) hs-datain(hs-datain_opaque); + +usb_wakeup(hs-dev); } static void usb_mouse_event(void *opaque, -- 1.7.1
[Qemu-devel] [PATCH 08/14] Make error handling more consistent in img_create() and img_resize()
From: Jes Sorensen jes.soren...@redhat.com Signed-off-by: Jes Sorensen jes.soren...@redhat.com Signed-off-by: Kevin Wolf kw...@redhat.com --- qemu-img.c | 18 -- 1 files changed, 12 insertions(+), 6 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 6fd52e9..5b6e648 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -349,13 +349,15 @@ static int img_create(int argc, char **argv) drv = bdrv_find_format(fmt); if (!drv) { error(Unknown file format '%s', fmt); -return 1; +ret = -1; +goto out; } proto_drv = bdrv_find_protocol(filename); if (!proto_drv) { error(Unknown protocol '%s', filename); -return 1; +ret = -1; +goto out; } create_options = append_option_parameters(create_options, @@ -1492,7 +1494,7 @@ static int img_resize(int argc, char **argv) int c, ret, relative; const char *filename, *fmt, *size; int64_t n, total_size; -BlockDriverState *bs; +BlockDriverState *bs = NULL; QEMUOptionParameter *param; QEMUOptionParameter resize_options[] = { { @@ -1544,14 +1546,16 @@ static int img_resize(int argc, char **argv) param = parse_option_parameters(, resize_options, NULL); if (set_option_parameter(param, BLOCK_OPT_SIZE, size)) { /* Error message already printed when size parsing fails */ -exit(1); +ret = -1; +goto out; } n = get_option_parameter(param, BLOCK_OPT_SIZE)-value.n; free_option_parameters(param); bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_RDWR); if (!bs) { -return 1; +ret = -1; +goto out; } if (relative) { @@ -1581,7 +1585,9 @@ static int img_resize(int argc, char **argv) break; } out: -bdrv_delete(bs); +if (bs) { +bdrv_delete(bs); +} if (ret) { return 1; } -- 1.7.2.3
[Qemu-devel] Invitation to connect on LinkedIn
LinkedIn Anbang Ruan requested to add you as a connection on LinkedIn: -- Jiajun, I'd like to add you to my professional network on LinkedIn. - Anbang Accept invitation from Anbang Ruan http://www.linkedin.com/e/-kkb1ec-ghhmmrcc-5/qTMmi8QEI_f3FNXUkL1mvZgy00BGYniwg3/blk/I77735332_11/pmpxnSRJrSdvj4R5fnhv9ClRsDgZp6lQs6lzoQ5AomZIpn8_cj5vczcPdjcTdPt9bQFzu71PkjkRbP8Rej4PcjoMc38LrCBxbOYWrSlI/EML_comm_afe/ View invitation from Anbang Ruan http://www.linkedin.com/e/-kkb1ec-ghhmmrcc-5/qTMmi8QEI_f3FNXUkL1mvZgy00BGYniwg3/blk/I77735332_11/0NclYOcPcRcPsTdQALqnpPbOYWrSlI/svi/ -- (c) 2010, LinkedIn Corporation
[Qemu-devel] Re: [PATCH] fix qruncom compilation problems
On 12/08/2010 10:43 PM, Stefano Bonifazi wrote: I've linked qemu-malloc.o and cutils.o together with qruncom.c and I managed to succesfully make it! here the make line: #$(MAKE) -C ../i386-linux-user libqemu.a $(CC) $(CFLAGS) -fomit-frame-pointer $(LDFLAGS) -I../target-i386 -I.. -I../linux-user -I../i386-linux-user -I../fpu \ -o $@ ../qemu-malloc.o ../cutils.o $(filter %.c, $^) -L../i386-linux-user -lqemu -lm Anyway running it with a com file as argument gave the error: mmap: Operation not permitted I think the problem is with MAP_FIXED parameter in mmap (http://opengroup.org/onlinepubs/007908799/xsh/mmap.html) having chosen 0x as starting address.. but it is pretty difficult for me atm to understand it, I've never used this function before and I am a beginner in these topics Removing that parameter mmap succeeds, but then I get segmentation fault in cpu_init You have to run it as root I think. Paolo
[Qemu-devel] [PATCH 12/14] qemu-option: Fix parse_option_parameters() documentation typo
From: Stefan Hajnoczi stefa...@linux.vnet.ibm.com Yoda said, list is the templace is. Fix this. Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com Signed-off-by: Kevin Wolf kw...@redhat.com --- qemu-option.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qemu-option.c b/qemu-option.c index e380fc1..65db542 100644 --- a/qemu-option.c +++ b/qemu-option.c @@ -394,8 +394,8 @@ QEMUOptionParameter *append_option_parameters(QEMUOptionParameter *dest, /* * Parses a parameter string (param) into an option list (dest). * - * list is the templace is. If dest is NULL, a new copy of list is created for - * it. If list is NULL, this function fails. + * list is the template option list. If dest is NULL, a new copy of list is + * created. If list is NULL, this function fails. * * A parameter string consists of one or more parameters, separated by commas. * Each parameter consists of its name and possibly of a value. In the latter -- 1.7.2.3
[Qemu-devel] [PATCH 23/24] usb storage: high speed support
Add high speed support to the usb mass storage device. With this patch applied the linux kernel recognises the usb storage device as highspeed capable device and suggests to connect it to a highspeed port instead of the uhci. Tested with both uhci and (not-yet submitted) ehci. Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/usb-msd.c | 51 ++- 1 files changed, 46 insertions(+), 5 deletions(-) diff --git a/hw/usb-msd.c b/hw/usb-msd.c index 74e657e..7b8189f 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -77,15 +77,19 @@ enum { STR_MANUFACTURER = 1, STR_PRODUCT, STR_SERIALNUMBER, +STR_CONFIG_FULL, +STR_CONFIG_HIGH, }; static const USBDescStrings desc_strings = { [STR_MANUFACTURER] = QEMU QEMU_VERSION, [STR_PRODUCT] = QEMU USB HARDDRIVE, [STR_SERIALNUMBER] = 1, +[STR_CONFIG_FULL] = Full speed config (usb 1.1), +[STR_CONFIG_HIGH] = High speed config (usb 2.0), }; -static const USBDescIface desc_iface0 = { +static const USBDescIface desc_iface_full = { .bInterfaceNumber = 0, .bNumEndpoints = 2, .bInterfaceClass = USB_CLASS_MASS_STORAGE, @@ -104,16 +108,51 @@ static const USBDescIface desc_iface0 = { } }; -static const USBDescDevice desc_device = { -.bcdUSB= 0x0100, +static const USBDescDevice desc_device_full = { +.bcdUSB= 0x0200, .bMaxPacketSize0 = 8, .bNumConfigurations= 1, .confs = (USBDescConfig[]) { { .bNumInterfaces= 1, .bConfigurationValue = 1, +.iConfiguration= STR_CONFIG_FULL, .bmAttributes = 0xc0, -.ifs = desc_iface0, +.ifs = desc_iface_full, +}, +}, +}; + +static const USBDescIface desc_iface_high = { +.bInterfaceNumber = 0, +.bNumEndpoints = 2, +.bInterfaceClass = USB_CLASS_MASS_STORAGE, +.bInterfaceSubClass= 0x06, /* SCSI */ +.bInterfaceProtocol= 0x50, /* Bulk */ +.eps = (USBDescEndpoint[]) { +{ +.bEndpointAddress = USB_DIR_IN | 0x01, +.bmAttributes = USB_ENDPOINT_XFER_BULK, +.wMaxPacketSize= 512, +},{ +.bEndpointAddress = USB_DIR_OUT | 0x02, +.bmAttributes = USB_ENDPOINT_XFER_BULK, +.wMaxPacketSize= 512, +}, +} +}; + +static const USBDescDevice desc_device_high = { +.bcdUSB= 0x0200, +.bMaxPacketSize0 = 64, +.bNumConfigurations= 1, +.confs = (USBDescConfig[]) { +{ +.bNumInterfaces= 1, +.bConfigurationValue = 1, +.iConfiguration= STR_CONFIG_HIGH, +.bmAttributes = 0xc0, +.ifs = desc_iface_high, }, }, }; @@ -127,7 +166,8 @@ static const USBDesc desc = { .iProduct = STR_PRODUCT, .iSerialNumber = STR_SERIALNUMBER, }, -.full = desc_device, +.full = desc_device_full, +.high = desc_device_high, .str = desc_strings, }; @@ -558,6 +598,7 @@ static struct USBDeviceInfo msd_info = { .usb_desc = desc, .init = usb_msd_initfn, .handle_packet = usb_generic_handle_packet, +.handle_attach = usb_desc_attach, .handle_reset = usb_msd_handle_reset, .handle_control = usb_msd_handle_control, .handle_data= usb_msd_handle_data, -- 1.7.1
[Qemu-devel] [PATCH 2/6] qemu, qmp: convert do_inject_nmi() to QObject
Convert do_inject_nmi() to QObject, we need to use it(via libvirt). It is trivial, as it never fails, doesn't have output nor return any data. Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- diff --git a/hmp-commands.hx b/hmp-commands.hx index 7a49b74..2e6b034 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -725,7 +725,8 @@ ETEXI .args_type = cpu_index:i, .params = cpu, .help = inject an NMI on the given CPU, -.mhandler.cmd = do_inject_nmi, +.user_print = monitor_user_noop, +.mhandler.cmd_new = do_inject_nmi, }, #endif STEXI diff --git a/monitor.c b/monitor.c index 729a7cb..1f0d29e 100644 --- a/monitor.c +++ b/monitor.c @@ -2120,7 +2120,7 @@ static void do_wav_capture(Monitor *mon, const QDict *qdict) #endif #if defined(TARGET_I386) -static void do_inject_nmi(Monitor *mon, const QDict *qdict) +static int do_inject_nmi(Monitor *mon, const QDict *qdict, QObject **ret_data) { CPUState *env; int cpu_index = qdict_get_int(qdict, cpu_index); @@ -2130,6 +2130,7 @@ static void do_inject_nmi(Monitor *mon, const QDict *qdict) cpu_interrupt(env, CPU_INTERRUPT_NMI); break; } +return 0; } #endif diff --git a/qmp-commands.hx b/qmp-commands.hx index a385b66..2506981 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -453,6 +453,22 @@ Example: EQMP +#if defined(TARGET_I386) +{ +.name = nmi, +.args_type = cpu_index:i, +.params = cpu, +.help = inject an NMI on the given CPU, +.user_print = monitor_user_noop, +.mhandler.cmd_new = do_inject_nmi, +}, +#endif +SQMP +...@item nmi @var{cpu} +...@findex nmi +Inject an NMI on the given CPU (x86 only). +EQMP + { .name = migrate, .args_type = detach:-d,blk:-b,inc:-i,uri:s,
[Qemu-devel] Re: [PATCH v5 0/2] Clean up img_create() and introduce strtosz_suffix()
Reviewed-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
[Qemu-devel] [PATCH 14/14] qemu-img: Fail creation if backing format is invalid
From: Stefan Hajnoczi stefa...@linux.vnet.ibm.com The qemu-img create command should check the backing format to ensure only image files with valid backing formats are created. By checking in qemu-img.c we can print a useful error message. Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com Signed-off-by: Kevin Wolf kw...@redhat.com --- qemu-img.c | 22 -- 1 files changed, 12 insertions(+), 10 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index c5a173c..52282e3 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -288,6 +288,7 @@ static int img_create(int argc, char **argv) const char *base_filename = NULL; BlockDriver *drv, *proto_drv; QEMUOptionParameter *param = NULL, *create_options = NULL; +QEMUOptionParameter *backing_fmt = NULL; char *options = NULL; for(;;) { @@ -379,14 +380,22 @@ static int img_create(int argc, char **argv) goto out; } +backing_fmt = get_option_parameter(param, BLOCK_OPT_BACKING_FMT); +if (backing_fmt backing_fmt-value.s) { +if (!bdrv_find_format(backing_fmt-value.s)) { +error(Unknown backing file format '%s', + backing_fmt-value.s); +ret = -1; +goto out; +} +} + // The size for the image must always be specified, with one exception: // If we are using a backing file, we can obtain the size from there if (get_option_parameter(param, BLOCK_OPT_SIZE)-value.n == -1) { QEMUOptionParameter *backing_file = get_option_parameter(param, BLOCK_OPT_BACKING_FILE); -QEMUOptionParameter *backing_fmt = -get_option_parameter(param, BLOCK_OPT_BACKING_FMT); if (backing_file backing_file-value.s) { BlockDriverState *bs; @@ -395,14 +404,7 @@ static int img_create(int argc, char **argv) char buf[32]; if (backing_fmt backing_fmt-value.s) { - if (bdrv_find_format(backing_fmt-value.s)) { - fmt = backing_fmt-value.s; -} else { - error(Unknown backing file format '%s', -backing_fmt-value.s); - ret = -1; - goto out; -} +fmt = backing_fmt-value.s; } bs = bdrv_new_open(backing_file-value.s, fmt, BDRV_O_FLAGS); -- 1.7.2.3
[Qemu-devel] [Bug 687733] [NEW] Linux KSM not compiled in (MADV_MERGEABLE always undef)
Public bug reported: Linux KSM support is not enabled because MADV_MERGEABLE remains undefined. It seems that asm-generic/mman-common.h is not included. Maybe some kind of header dependency problem? Adding #include asm-generic/mman-common.h to exec.c of qemu-kvm-0.13.0 enables use of KSM and values change in /sys/kernel/mm/ksm/. Tested under CentOS 5.5 with custom kernel 2.6.32.26 and OpenSUSE 11.2 with custom kernel 2.6.36.1, both x86_64 platform. Please note that I configure with--kerneldir=/lib/modules/2.6.../build and even --extra-cflags=-I/lib/modules/2.6.../build/include. ** Affects: qemu Importance: Undecided Status: New -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/687733 Title: Linux KSM not compiled in (MADV_MERGEABLE always undef) Status in QEMU: New Bug description: Linux KSM support is not enabled because MADV_MERGEABLE remains undefined. It seems that asm-generic/mman-common.h is not included. Maybe some kind of header dependency problem? Adding #include asm-generic/mman-common.h to exec.c of qemu-kvm-0.13.0 enables use of KSM and values change in /sys/kernel/mm/ksm/. Tested under CentOS 5.5 with custom kernel 2.6.32.26 and OpenSUSE 11.2 with custom kernel 2.6.36.1, both x86_64 platform. Please note that I configure with--kerneldir=/lib/modules/2.6.../build and even --extra-cflags=-I/lib/modules/2.6.../build/include.
[Qemu-devel] [PATCH 0/2] Fix size default for qemu-img
From: Jes Sorensen jes.soren...@redhat.com Kevin pointed out that my chance to img_create()'s handling of the image size, changed the previous default of byte for size if no suffix was specified, since strtosz() defaults to MB. This patch set introduces strtosz_suffix() and then changes img_create() to use that instead, thereby restoring the old default behavior. Jes Sorensen (2): Introduce strtosz_suffix() Make img_create() use strtosz_suffix() cutils.c | 17 ++--- qemu-common.h |7 +++ qemu-img.c|2 +- 3 files changed, 22 insertions(+), 4 deletions(-) -- 1.7.3.2
[Qemu-devel] [PATCH 00/24] usb descriptor overhaul.
Hi, This patch series is the start for an overhaul of the usb descriptor handling for emulated usb devices. Instead of storing the device desriptors in blobs (aka char arrays) they are stored in structs, which makes it alot easier to work with them. This in turn allows to move common device management to common code and also makes it alot easier to add high speed support to the emulated devices. The patch series also features some usb subsystem cleanups and fixes, remote wakeup support for hid devices and some preparing bits for high-speed support. The patches are also available in the git repository at: git://anongit.freedesktop.org/spice/qemu usb.2 cheers, Gerd PS: There is also a usb.2.wip branch in the git repo with some more wip/experimental/debug patches for those who what to play with ehci. Gerd Hoffmann (24): usb: data structs and helpers for usb descriptors. usb hid: use new descriptor infrastructure. usb serial: use new descriptor infrastructure. usb storage: use new descriptor infrastructure. usb wacom: use new descriptor infrastructure. usb bluetooth: use new descriptor infrastructure. usb hub: use new descriptor infrastructure. usb descriptors: add settable strings. usb storage: serial number support usb network: use new descriptor infrastructure. usb: move USB_REQ_SET_ADDRESS handling to common code usb: move USB_REQ_{GET,SET}_CONFIGURATION handling to common code usb: move remote wakeup handling to common code usb: create USBPortOps, move attach there. usb: rework attach/detach workflow usb: add usb_wakeup() + wakeup callback to port ops usb: uhci: remote wakeup support. usb: hid: remote wakeup support. usb: add speed mask to ports usb: add attach callback usb: add usb_desc_attach usb: add device qualifier support usb storage: high speed support usb storage: fix status reporting Makefile.objs |2 +- hw/usb-bt.c | 525 ++ hw/usb-bus.c|6 +- hw/usb-desc.c | 406 ++ hw/usb-desc.h | 92 ++ hw/usb-hid.c| 486 ++- hw/usb-hub.c| 227 +++- hw/usb-msd.c| 263 --- hw/usb-musb.c | 43 ++--- hw/usb-net.c| 528 +++ hw/usb-ohci.c | 87 +- hw/usb-serial.c | 236 + hw/usb-uhci.c | 97 ++- hw/usb-wacom.c | 214 --- hw/usb.c| 34 - hw/usb.h| 46 +- trace-events| 11 ++ 17 files changed, 1736 insertions(+), 1567 deletions(-) create mode 100644 hw/usb-desc.c create mode 100644 hw/usb-desc.h
[Qemu-devel] [PATCH 05/14] Consolidate printing of block driver options
From: Jes Sorensen jes.soren...@redhat.com This consolidates the printing of block driver options in print_block_option_help() which is called from both img_create() and img_convert(). This allows for the ? detection to be done just after the parsing of options and the filename, instead of half way down the codepath of these functions. Signed-off-by: Jes Sorensen jes.soren...@redhat.com Signed-off-by: Kevin Wolf kw...@redhat.com --- qemu-img.c | 46 +- 1 files changed, 37 insertions(+), 9 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index aded72d..50cfdda 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -188,6 +188,33 @@ static int read_password(char *buf, int buf_size) } #endif +static int print_block_option_help(const char *filename, const char *fmt) +{ +BlockDriver *drv, *proto_drv; +QEMUOptionParameter *create_options = NULL; + +/* Find driver and parse its options */ +drv = bdrv_find_format(fmt); +if (!drv) { +error(Unknown file format '%s', fmt); +return 1; +} + +proto_drv = bdrv_find_protocol(filename); +if (!proto_drv) { +error(Unknown protocol '%s', filename); +return 1; +} + +create_options = append_option_parameters(create_options, + drv-create_options); +create_options = append_option_parameters(create_options, + proto_drv-create_options); +print_option_help(create_options); +free_option_parameters(create_options); +return 0; +} + static BlockDriverState *bdrv_new_open(const char *filename, const char *fmt, int flags) @@ -310,6 +337,11 @@ static int img_create(int argc, char **argv) help(); filename = argv[optind++]; +if (options !strcmp(options, ?)) { +ret = print_block_option_help(filename, fmt); +goto out; +} + /* Find driver and parse its options */ drv = bdrv_find_format(fmt); if (!drv) { @@ -328,11 +360,6 @@ static int img_create(int argc, char **argv) create_options = append_option_parameters(create_options, proto_drv-create_options); -if (options !strcmp(options, ?)) { -print_option_help(create_options); -goto out; -} - /* Create parameter list with default values */ param = parse_option_parameters(, create_options, param); set_option_parameter_int(param, BLOCK_OPT_SIZE, -1); @@ -694,6 +721,11 @@ static int img_convert(int argc, char **argv) out_filename = argv[argc - 1]; +if (options !strcmp(options, ?)) { +ret = print_block_option_help(out_filename, out_fmt); +goto out; +} + if (bs_n 1 out_baseimg) { error(-B makes no sense when concatenating multiple input images); ret = -1; @@ -746,10 +778,6 @@ static int img_convert(int argc, char **argv) drv-create_options); create_options = append_option_parameters(create_options, proto_drv-create_options); -if (options !strcmp(options, ?)) { -print_option_help(create_options); -goto out; -} if (options) { param = parse_option_parameters(options, create_options, param); -- 1.7.2.3
[Qemu-devel] [PATCH 10/14] qemu-img: Deprecate obsolete -6 and -e options
From: Jes Sorensen jes.soren...@redhat.com If -6 or -e is specified, an error message is printed and we exit. It does not print help() to avoid the error message getting lost in the noise. Signed-off-by: Jes Sorensen jes.soren...@redhat.com Signed-off-by: Kevin Wolf kw...@redhat.com --- block_int.h |1 - qemu-img.c | 53 ++--- 2 files changed, 22 insertions(+), 32 deletions(-) diff --git a/block_int.h b/block_int.h index 3c3adb5..3ceed47 100644 --- a/block_int.h +++ b/block_int.h @@ -29,7 +29,6 @@ #include qemu-queue.h #define BLOCK_FLAG_ENCRYPT 1 -#define BLOCK_FLAG_COMPRESS2 #define BLOCK_FLAG_COMPAT6 4 #define BLOCK_OPT_SIZE size diff --git a/qemu-img.c b/qemu-img.c index 5b6e648..d146d8c 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -261,21 +261,9 @@ fail: } static int add_old_style_options(const char *fmt, QEMUOptionParameter *list, -int flags, const char *base_filename, const char *base_fmt) + const char *base_filename, + const char *base_fmt) { -if (flags BLOCK_FLAG_ENCRYPT) { -if (set_option_parameter(list, BLOCK_OPT_ENCRYPT, on)) { -error(Encryption not supported for file format '%s', fmt); -return -1; -} -} -if (flags BLOCK_FLAG_COMPAT6) { -if (set_option_parameter(list, BLOCK_OPT_COMPAT6, on)) { -error(VMDK version 6 not supported for file format '%s', fmt); -return -1; -} -} - if (base_filename) { if (set_option_parameter(list, BLOCK_OPT_BACKING_FILE, base_filename)) { error(Backing file not supported for file format '%s', fmt); @@ -293,7 +281,7 @@ static int add_old_style_options(const char *fmt, QEMUOptionParameter *list, static int img_create(int argc, char **argv) { -int c, ret = 0, flags; +int c, ret = 0; const char *fmt = raw; const char *base_fmt = NULL; const char *filename; @@ -302,7 +290,6 @@ static int img_create(int argc, char **argv) QEMUOptionParameter *param = NULL, *create_options = NULL; char *options = NULL; -flags = 0; for(;;) { c = getopt(argc, argv, F:b:f:he6o:); if (c == -1) { @@ -323,11 +310,13 @@ static int img_create(int argc, char **argv) fmt = optarg; break; case 'e': -flags |= BLOCK_FLAG_ENCRYPT; -break; +error(qemu-img: option -e is deprecated, please use \'-o + encryption\' instead!); +return 1; case '6': -flags |= BLOCK_FLAG_COMPAT6; -break; +error(qemu-img: option -6 is deprecated, please use \'-o + compat6\' instead!); +return 1; case 'o': options = optarg; break; @@ -385,7 +374,7 @@ static int img_create(int argc, char **argv) } /* Add old-style options to parameters */ -ret = add_old_style_options(fmt, param, flags, base_filename, base_fmt); +ret = add_old_style_options(fmt, param, base_filename, base_fmt); if (ret 0) { goto out; } @@ -674,7 +663,7 @@ static int compare_sectors(const uint8_t *buf1, const uint8_t *buf2, int n, static int img_convert(int argc, char **argv) { -int c, ret = 0, n, n1, bs_n, bs_i, flags, cluster_size, cluster_sectors; +int c, ret = 0, n, n1, bs_n, bs_i, compress, cluster_size, cluster_sectors; const char *fmt, *out_fmt, *out_baseimg, *out_filename; BlockDriver *drv, *proto_drv; BlockDriverState **bs = NULL, *out_bs = NULL; @@ -691,7 +680,7 @@ static int img_convert(int argc, char **argv) fmt = NULL; out_fmt = raw; out_baseimg = NULL; -flags = 0; +compress = 0; for(;;) { c = getopt(argc, argv, f:O:B:s:hce6o:); if (c == -1) { @@ -712,14 +701,16 @@ static int img_convert(int argc, char **argv) out_baseimg = optarg; break; case 'c': -flags |= BLOCK_FLAG_COMPRESS; +compress = 1; break; case 'e': -flags |= BLOCK_FLAG_ENCRYPT; -break; +error(qemu-img: option -e is deprecated, please use \'-o + encryption\' instead!); +return 1; case '6': -flags |= BLOCK_FLAG_COMPAT6; -break; +error(qemu-img: option -6 is deprecated, please use \'-o + compat6\' instead!); +return 1; case 'o': options = optarg; break; @@ -806,7 +797,7 @@ static int img_convert(int argc, char **argv) } set_option_parameter_int(param, BLOCK_OPT_SIZE, total_sectors * 512); -ret = add_old_style_options(out_fmt, param, flags, out_baseimg, NULL); +ret = add_old_style_options(out_fmt, param, out_baseimg, NULL); if (ret 0) { goto
[Qemu-devel] [PATCH 1/1] Introduce strtosz_suffix()
From: Jes Sorensen jes.soren...@redhat.com This introduces strtosz_suffix() which allows the caller to specify a default suffix in case the non default of MB is wanted. strtosz() is kept as a wrapper for strtosz_suffix() which keeps it's current default of MB. Signed-off-by: Jes Sorensen jes.soren...@redhat.com --- cutils.c | 17 ++--- qemu-common.h |7 +++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/cutils.c b/cutils.c index 28089aa..1d24d9a 100644 --- a/cutils.c +++ b/cutils.c @@ -291,10 +291,10 @@ int fcntl_setfl(int fd, int flag) * value must be terminated by whitespace, ',' or '\0'. Return -1 on * error. */ -ssize_t strtosz(const char *nptr, char **end) +ssize_t strtosz_suffix(const char *nptr, char **end, const char default_suffix) { ssize_t retval = -1; -char *endptr, c; +char *endptr, c, d; int mul_required = 0; double val, mul, integral, fraction; @@ -313,10 +313,16 @@ ssize_t strtosz(const char *nptr, char **end) * part of a multi token argument. */ c = *endptr; +d = c; if (isspace(c) || c == '\0' || c == ',') { c = 0; +if (default_suffix) { +d = default_suffix; +} else { +d = c; +} } -switch (c) { +switch (d) { case 'B': case 'b': mul = 1; @@ -371,3 +377,8 @@ fail: return retval; } + +ssize_t strtosz(const char *nptr, char **end) +{ +return strtosz_suffix(nptr, end, 0); +} diff --git a/qemu-common.h b/qemu-common.h index de82c2e..dc44cd6 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -149,7 +149,14 @@ time_t mktimegm(struct tm *tm); int qemu_fls(int i); int qemu_fdatasync(int fd); int fcntl_setfl(int fd, int flag); + +#define STRTOSZ_DEFSUFFIX_TB 'T' +#define STRTOSZ_DEFSUFFIX_GB 'G' +#define STRTOSZ_DEFSUFFIX_MB 'M' +#define STRTOSZ_DEFSUFFIX_KB 'K' +#define STRTOSZ_DEFSUFFIX_B'B' ssize_t strtosz(const char *nptr, char **end); +ssize_t strtosz_suffix(const char *nptr, char **end, const char); /* path.c */ void init_paths(const char *prefix); -- 1.7.3.2
[Qemu-devel] [PATCH 03/24] usb serial: use new descriptor infrastructure.
Switch the usb serial drivers (serial, braille) over to the new descriptor infrastructure. Note that this removes the freely configurable vendor and product id properties. I think the only reason this was configurable is that the only difference between the serial and the braille device is the vendor+product id. Of course the serial and braille devices keep their different IDs, but they can't be overritten from the command line any more. Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/usb-serial.c | 200 +++ 1 files changed, 83 insertions(+), 117 deletions(-) diff --git a/hw/usb-serial.c b/hw/usb-serial.c index c19580f..f89eb9b 100644 --- a/hw/usb-serial.c +++ b/hw/usb-serial.c @@ -11,6 +11,7 @@ #include qemu-common.h #include qemu-error.h #include usb.h +#include usb-desc.h #include qemu-char.h //#define DEBUG_Serial @@ -91,8 +92,6 @@ do { printf(usb-serial: fmt , ## __VA_ARGS__); } while (0) typedef struct { USBDevice dev; -uint32_t vendorid; -uint32_t productid; uint8_t recv_buf[RECV_BUF]; uint16_t recv_ptr; uint16_t recv_used; @@ -104,69 +103,78 @@ typedef struct { CharDriverState *cs; } USBSerialState; -static const uint8_t qemu_serial_dev_descriptor[] = { -0x12, /* u8 bLength; */ -0x01, /* u8 bDescriptorType; Device */ -0x00, 0x02, /* u16 bcdUSB; v2.0 */ - -0x00, /* u8 bDeviceClass; */ -0x00, /* u8 bDeviceSubClass; */ -0x00, /* u8 bDeviceProtocol; [ low/full speeds only ] */ -0x08, /* u8 bMaxPacketSize0; 8 Bytes */ - -/* Vendor and product id are arbitrary. */ -0x03, 0x04, /* u16 idVendor; */ -0x00, 0xFF, /* u16 idProduct; */ -0x00, 0x04, /* u16 bcdDevice */ - -0x01, /* u8 iManufacturer; */ -0x02, /* u8 iProduct; */ -0x03, /* u8 iSerialNumber; */ -0x01/* u8 bNumConfigurations; */ +enum { +STR_MANUFACTURER = 1, +STR_PRODUCT_SERIAL, +STR_PRODUCT_BRAILLE, +STR_SERIALNUMBER, }; -static const uint8_t qemu_serial_config_descriptor[] = { - -/* one configuration */ -0x09, /* u8 bLength; */ -0x02, /* u8 bDescriptorType; Configuration */ -0x20, 0x00, /* u16 wTotalLength; */ -0x01, /* u8 bNumInterfaces; (1) */ -0x01, /* u8 bConfigurationValue; */ -0x00, /* u8 iConfiguration; */ -0x80, /* u8 bmAttributes; - Bit 7: must be set, - 6: Self-powered, - 5: Remote wakeup, - 4..0: resvd */ -100/2, /* u8 MaxPower; */ - -/* one interface */ -0x09, /* u8 if_bLength; */ -0x04, /* u8 if_bDescriptorType; Interface */ -0x00, /* u8 if_bInterfaceNumber; */ -0x00, /* u8 if_bAlternateSetting; */ -0x02, /* u8 if_bNumEndpoints; */ -0xff, /* u8 if_bInterfaceClass; Vendor Specific */ -0xff, /* u8 if_bInterfaceSubClass; Vendor Specific */ -0xff, /* u8 if_bInterfaceProtocol; Vendor Specific */ -0x02, /* u8 if_iInterface; */ - -/* Bulk-In endpoint */ -0x07, /* u8 ep_bLength; */ -0x05, /* u8 ep_bDescriptorType; Endpoint */ -0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */ -0x02, /* u8 ep_bmAttributes; Bulk */ -0x40, 0x00, /* u16 ep_wMaxPacketSize; */ -0x00, /* u8 ep_bInterval; */ - -/* Bulk-Out endpoint */ -0x07, /* u8 ep_bLength; */ -0x05, /* u8 ep_bDescriptorType; Endpoint */ -0x02, /* u8 ep_bEndpointAddress; OUT Endpoint 2 */ -0x02, /* u8 ep_bmAttributes; Bulk */ -0x40, 0x00, /* u16 ep_wMaxPacketSize; */ -0x00/* u8 ep_bInterval; */ +static const USBDescStrings desc_strings = { +[STR_MANUFACTURER]= QEMU QEMU_VERSION, +[STR_PRODUCT_SERIAL] = QEMU USB SERIAL, +[STR_PRODUCT_BRAILLE] = QEMU USB BRAILLE, +[STR_SERIALNUMBER]= 1, +}; + +static const USBDescIface desc_iface0 = { +.bInterfaceNumber = 0, +.bNumEndpoints = 2, +.bInterfaceClass = 0xff, +.bInterfaceSubClass= 0xff, +.bInterfaceProtocol= 0xff, +.eps = (USBDescEndpoint[]) { +{ +.bEndpointAddress = USB_DIR_IN | 0x01, +.bmAttributes = USB_ENDPOINT_XFER_BULK, +.wMaxPacketSize= 64, +},{ +.bEndpointAddress = USB_DIR_OUT | 0x02, +.bmAttributes = USB_ENDPOINT_XFER_BULK, +.wMaxPacketSize= 64, +}, +}
[Qemu-devel] [PATCH] kvm: x86: Save/restore error_code
The saving and restoring of error_code seems lost and convert the error_code to uint32_t. Signed-off-by: Jason Wang jasow...@redhat.com --- target-i386/cpu.h |4 ++-- target-i386/machine.c |2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 06e40f3..c990db9 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -688,7 +688,7 @@ typedef struct CPUX86State { uint64_t pat; /* exception/interrupt handling */ -int error_code; +uint32_t error_code; int exception_is_int; target_ulong exception_next_eip; target_ulong dr[8]; /* debug registers */ @@ -933,7 +933,7 @@ uint64_t cpu_get_tsc(CPUX86State *env); #define cpu_list_id x86_cpu_list #define cpudef_setup x86_cpudef_setup -#define CPU_SAVE_VERSION 12 +#define CPU_SAVE_VERSION 13 /* MMU modes definitions */ #define MMU_MODE0_SUFFIX _kernel diff --git a/target-i386/machine.c b/target-i386/machine.c index d78eceb..0e467da 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -491,6 +491,8 @@ static const VMStateDescription vmstate_cpu = { VMSTATE_UINT64_V(xcr0, CPUState, 12), VMSTATE_UINT64_V(xstate_bv, CPUState, 12), VMSTATE_YMMH_REGS_VARS(ymmh_regs, CPUState, CPU_NB_REGS, 12), + +VMSTATE_UINT32_V(error_code, CPUState, 13), VMSTATE_END_OF_LIST() /* The above list is not sorted /wrt version numbers, watch out! */ },
[Qemu-devel] [PATCH 11/14] qemu-option: Don't reinvent append_option_parameters()
From: Stefan Hajnoczi stefa...@linux.vnet.ibm.com parse_option_parameters() may need to create a new option parameter list from a template list. Use append_option_parameters() instead of duplicating the code. Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com Signed-off-by: Kevin Wolf kw...@redhat.com --- qemu-option.c |9 + 1 files changed, 1 insertions(+), 8 deletions(-) diff --git a/qemu-option.c b/qemu-option.c index 1f8f41a..e380fc1 100644 --- a/qemu-option.c +++ b/qemu-option.c @@ -416,20 +416,13 @@ QEMUOptionParameter *parse_option_parameters(const char *param, char value[256]; char *param_delim, *value_delim; char next_delim; -size_t num_options; if (list == NULL) { return NULL; } if (dest == NULL) { -// Count valid options -num_options = count_option_parameters(list); - -// Create a copy of the option list to fill in values -dest = qemu_mallocz((num_options + 1) * sizeof(QEMUOptionParameter)); -allocated = dest; -memcpy(dest, list, (num_options + 1) * sizeof(QEMUOptionParameter)); +dest = allocated = append_option_parameters(NULL, list); } while (*param) { -- 1.7.2.3
[Qemu-devel] [PATCH] migration: ide: drop ide_pci_post_load()
When the bmdma transfering ended, the unit were set to -1(0xFF), but after migration ide_pci_post_load() would change it to 1. This is not intended and it also would break the migration stability that we could not get exactly the same exec file before and after migration. So this patch drop the ide_pci_post_load() and it would also make possible to debugging of migration through comparing the exec files. Signed-off-by: Jason Wang jasow...@redhat.com I'm not sure whether this is the best way to handle this issue. Should we still care about the migration from old guest? --- hw/ide/pci.c | 14 -- 1 files changed, 0 insertions(+), 14 deletions(-) diff --git a/hw/ide/pci.c b/hw/ide/pci.c index ec90f26..b9ef122 100644 --- a/hw/ide/pci.c +++ b/hw/ide/pci.c @@ -186,25 +186,11 @@ static const VMStateDescription vmstate_bmdma = { } }; -static int ide_pci_post_load(void *opaque, int version_id) -{ -PCIIDEState *d = opaque; -int i; - -for(i = 0; i 2; i++) { -/* current versions always store 0/1, but older version - stored bigger values. We only need last bit */ -d-bmdma[i].unit = 1; -} -return 0; -} - const VMStateDescription vmstate_ide_pci = { .name = ide, .version_id = 3, .minimum_version_id = 0, .minimum_version_id_old = 0, -.post_load = ide_pci_post_load, .fields = (VMStateField []) { VMSTATE_PCI_DEVICE(dev, PCIIDEState), VMSTATE_STRUCT_ARRAY(bmdma, PCIIDEState, 2, 0,
[Qemu-devel] [PATCH 19/24] usb: add speed mask to ports
Add a field to usb ports indicating the speed(s) they are able to handle. Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/usb-bus.c |3 ++- hw/usb-hub.c |3 ++- hw/usb-musb.c |3 ++- hw/usb-ohci.c |3 ++- hw/usb-uhci.c |3 ++- hw/usb.h |9 - 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/hw/usb-bus.c b/hw/usb-bus.c index f534bc3..9772e1e 100644 --- a/hw/usb-bus.c +++ b/hw/usb-bus.c @@ -111,11 +111,12 @@ USBDevice *usb_create_simple(USBBus *bus, const char *name) } void usb_register_port(USBBus *bus, USBPort *port, void *opaque, int index, - USBPortOps *ops) + USBPortOps *ops, int speedmask) { port-opaque = opaque; port-index = index; port-ops = ops; +port-speedmask = speedmask; QTAILQ_INSERT_TAIL(bus-free, port, next); bus-nfree++; } diff --git a/hw/usb-hub.c b/hw/usb-hub.c index 5aa1d0b..652a9d5 100644 --- a/hw/usb-hub.c +++ b/hw/usb-hub.c @@ -514,7 +514,8 @@ static int usb_hub_initfn(USBDevice *dev) for (i = 0; i NUM_PORTS; i++) { port = s-ports[i]; usb_register_port(usb_bus_from_device(dev), - port-port, s, i, usb_hub_port_ops); + port-port, s, i, usb_hub_port_ops, + USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL); port-wPortStatus = PORT_STAT_POWER; port-wPortChange = 0; } diff --git a/hw/usb-musb.c b/hw/usb-musb.c index 0c5b5d6..ac7b684 100644 --- a/hw/usb-musb.c +++ b/hw/usb-musb.c @@ -349,7 +349,8 @@ struct MUSBState { } usb_bus_new(s-bus, NULL /* FIXME */); -usb_register_port(s-bus, s-port, s, 0, musb_port_ops); +usb_register_port(s-bus, s-port, s, 0, musb_port_ops, + USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL); return s; } diff --git a/hw/usb-ohci.c b/hw/usb-ohci.c index ed6b3e7..32f5f69 100644 --- a/hw/usb-ohci.c +++ b/hw/usb-ohci.c @@ -1705,7 +1705,8 @@ static void usb_ohci_init(OHCIState *ohci, DeviceState *dev, usb_bus_new(ohci-bus, dev); ohci-num_ports = num_ports; for (i = 0; i num_ports; i++) { -usb_register_port(ohci-bus, ohci-rhport[i].port, ohci, i, ohci_port_ops); +usb_register_port(ohci-bus, ohci-rhport[i].port, ohci, i, ohci_port_ops, + USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL); } ohci-async_td = 0; diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c index 60d5d57..802352a 100644 --- a/hw/usb-uhci.c +++ b/hw/usb-uhci.c @@ -1129,7 +1129,8 @@ static int usb_uhci_common_initfn(UHCIState *s) usb_bus_new(s-bus, s-dev.qdev); for(i = 0; i NB_PORTS; i++) { -usb_register_port(s-bus, s-ports[i].port, s, i, uhci_port_ops); +usb_register_port(s-bus, s-ports[i].port, s, i, uhci_port_ops, + USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL); } s-frame_timer = qemu_new_timer(vm_clock, uhci_frame_timer, s); s-expire_time = qemu_get_clock(vm_clock) + diff --git a/hw/usb.h b/hw/usb.h index 9f454e6..864501a 100644 --- a/hw/usb.h +++ b/hw/usb.h @@ -44,6 +44,12 @@ #define USB_SPEED_LOW 0 #define USB_SPEED_FULL 1 #define USB_SPEED_HIGH 2 +#define USB_SPEED_SUPER 3 + +#define USB_SPEED_MASK_LOW (1 USB_SPEED_LOW) +#define USB_SPEED_MASK_FULL (1 USB_SPEED_FULL) +#define USB_SPEED_MASK_HIGH (1 USB_SPEED_HIGH) +#define USB_SPEED_MASK_SUPER (1 USB_SPEED_SUPER) #define USB_STATE_NOTATTACHED 0 #define USB_STATE_ATTACHED1 @@ -226,6 +232,7 @@ typedef struct USBPortOps { /* USB port on which a device can be connected */ struct USBPort { USBDevice *dev; +int speedmask; USBPortOps *ops; void *opaque; int index; /* internal port index, may be used with the opaque */ @@ -338,7 +345,7 @@ USBDevice *usb_create(USBBus *bus, const char *name); USBDevice *usb_create_simple(USBBus *bus, const char *name); USBDevice *usbdevice_create(const char *cmdline); void usb_register_port(USBBus *bus, USBPort *port, void *opaque, int index, - USBPortOps *ops); + USBPortOps *ops, int speedmask); void usb_unregister_port(USBBus *bus, USBPort *port); int usb_device_attach(USBDevice *dev); int usb_device_detach(USBDevice *dev); -- 1.7.1
Re: [Qemu-devel] State of EHCI emulation for QEMU
Hi, New features developed for the kernel are done in a separate git trees. When a feature is ready for inclusion into the main kernel tree, a pull request is sent. That workflow maintains a complete change history for the feature. Take performance events for example: you can go into Linus' git tree and see the complete history of changes. There's no reason the same methodology cannot be done for qemu. It is done for qemu, pci and block are maintained that way for example. The key difference is that the patches which are accepted into the subsystem branches and then are pulled go through a full review @ qemu-devel before. cheers, Gerd
[Qemu-devel] [PATCH 15/24] usb: rework attach/detach workflow
Add separate detach callback to USBPortOps, split uhci/ohci/musb/usbhub attach functions into two. Move common code to the usb_attach() function, only the hardware-specific bits remain in the attach/detach callbacks. Keep track of the port it is attached to for each usb device. Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/usb-hub.c | 46 ++-- hw/usb-musb.c | 36 - hw/usb-ohci.c | 80 +++-- hw/usb-uhci.c | 69 +--- hw/usb.c | 20 +- hw/usb.h |4 ++- 6 files changed, 122 insertions(+), 133 deletions(-) diff --git a/hw/usb-hub.c b/hw/usb-hub.c index 1de2e0f..5aa1d0b 100644 --- a/hw/usb-hub.c +++ b/hw/usb-hub.c @@ -218,37 +218,30 @@ static const uint8_t qemu_hub_hub_descriptor[] = /* DeviceRemovable and PortPwrCtrlMask patched in later */ }; -static void usb_hub_attach(USBPort *port1, USBDevice *dev) +static void usb_hub_attach(USBPort *port1) { USBHubState *s = port1-opaque; USBHubPort *port = s-ports[port1-index]; -if (dev) { -if (port-port.dev) -usb_attach(port1, NULL); - -port-wPortStatus |= PORT_STAT_CONNECTION; -port-wPortChange |= PORT_STAT_C_CONNECTION; -if (dev-speed == USB_SPEED_LOW) -port-wPortStatus |= PORT_STAT_LOW_SPEED; -else -port-wPortStatus = ~PORT_STAT_LOW_SPEED; -port-port.dev = dev; -/* send the attach message */ -usb_send_msg(dev, USB_MSG_ATTACH); +port-wPortStatus |= PORT_STAT_CONNECTION; +port-wPortChange |= PORT_STAT_C_CONNECTION; +if (port-port.dev-speed == USB_SPEED_LOW) { +port-wPortStatus |= PORT_STAT_LOW_SPEED; } else { -dev = port-port.dev; -if (dev) { -port-wPortStatus = ~PORT_STAT_CONNECTION; -port-wPortChange |= PORT_STAT_C_CONNECTION; -if (port-wPortStatus PORT_STAT_ENABLE) { -port-wPortStatus = ~PORT_STAT_ENABLE; -port-wPortChange |= PORT_STAT_C_ENABLE; -} -/* send the detach message */ -usb_send_msg(dev, USB_MSG_DETACH); -port-port.dev = NULL; -} +port-wPortStatus = ~PORT_STAT_LOW_SPEED; +} +} + +static void usb_hub_detach(USBPort *port1) +{ +USBHubState *s = port1-opaque; +USBHubPort *port = s-ports[port1-index]; + +port-wPortStatus = ~PORT_STAT_CONNECTION; +port-wPortChange |= PORT_STAT_C_CONNECTION; +if (port-wPortStatus PORT_STAT_ENABLE) { +port-wPortStatus = ~PORT_STAT_ENABLE; +port-wPortChange |= PORT_STAT_C_ENABLE; } } @@ -508,6 +501,7 @@ static void usb_hub_handle_destroy(USBDevice *dev) static USBPortOps usb_hub_port_ops = { .attach = usb_hub_attach, +.detach = usb_hub_detach, }; static int usb_hub_initfn(USBDevice *dev) diff --git a/hw/usb-musb.c b/hw/usb-musb.c index 916aa06..0c5b5d6 100644 --- a/hw/usb-musb.c +++ b/hw/usb-musb.c @@ -259,10 +259,12 @@ #endif -static void musb_attach(USBPort *port, USBDevice *dev); +static void musb_attach(USBPort *port); +static void musb_detach(USBPort *port); static USBPortOps musb_port_ops = { .attach = musb_attach, +.attach = musb_detach, }; typedef struct { @@ -464,34 +466,20 @@ static void musb_session_update(MUSBState *s, int prev_dev, int prev_sess) } /* Attach or detach a device on our only port. */ -static void musb_attach(USBPort *port, USBDevice *dev) +static void musb_attach(USBPort *port) { MUSBState *s = (MUSBState *) port-opaque; -USBDevice *curr; -port = s-port; -curr = port-dev; - -if (dev) { -if (curr) { -usb_attach(port, NULL); -/* TODO: signal some interrupts */ -} - -musb_intr_set(s, musb_irq_vbus_request, 1); - -/* Send the attach message to device */ -usb_send_msg(dev, USB_MSG_ATTACH); -} else if (curr) { -/* Send the detach message */ -usb_send_msg(curr, USB_MSG_DETACH); - -musb_intr_set(s, musb_irq_disconnect, 1); -} +musb_intr_set(s, musb_irq_vbus_request, 1); +musb_session_update(s, 0, s-session); +} -port-dev = dev; +static void musb_detach(USBPort *port) +{ +MUSBState *s = (MUSBState *) port-opaque; -musb_session_update(s, !!curr, s-session); +musb_intr_set(s, musb_irq_disconnect, 1); +musb_session_update(s, 1, s-session); } static inline void musb_cb_tick0(void *opaque) diff --git a/hw/usb-ohci.c b/hw/usb-ohci.c index 3f71291..ed6b3e7 100644 --- a/hw/usb-ohci.c +++ b/hw/usb-ohci.c @@ -322,52 +322,46 @@ static inline void ohci_set_interrupt(OHCIState *ohci, uint32_t intr) } /* Attach or detach a device on a root hub port. */ -static void ohci_attach(USBPort *port1, USBDevice *dev) +static void ohci_attach(USBPort *port1) { OHCIState *s = port1-opaque;
[Qemu-devel] Re: [PATCH] migration: ide: drop ide_pci_post_load()
Jason Wang jasow...@redhat.com wrote: When the bmdma transfering ended, the unit were set to -1(0xFF), but after migration ide_pci_post_load() would change it to 1. This is not intended and it also would break the migration stability that we could not get exactly the same exec file before and after migration. So this patch drop the ide_pci_post_load() and it would also make possible to debugging of migration through comparing the exec files. Signed-off-by: Jason Wang jasow...@redhat.com I'm not sure whether this is the best way to handle this issue. Should we still care about the migration from old guest? Basically we have unit=-1 when there is an error/we ended an operation. Stable image migration are having trouble with it, and we only generate 0/1/-1 nowadays. Acked-by: Juan Quintela quint...@redhat.com
[Qemu-devel] Re: [PATCH 1/7] usb-linux: introduce a usb_linux_alt_setting function
On 11/26/10 19:13, Hans de Goede wrote: The next patch in this series introduces multiple ways to get the alt setting dependent upon usb_fs_type, it is cleaner to put this into its own function. Note that this patch also changes the assumed alt setting in case of an error getting the alt setting to be 0 (a sane default) rather then the interface numberwhich makes no sense. Patch series looks good. Acked-by: Gerd Hoffmann kra...@redhat.com cheers, Gerd
[Qemu-devel] [PATCH 2/2] qemu-img.c: Clean up handling of image size in img_create()
From: Jes Sorensen jes.soren...@redhat.com This cleans up the handling of image size in img_create() by parsing the value early, and then only setting it once if a value has been added as the last argument to the command line. Signed-off-by: Jes Sorensen jes.soren...@redhat.com --- qemu-img.c | 23 +-- 1 files changed, 17 insertions(+), 6 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index d146d8c..f078718 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -282,6 +282,7 @@ static int add_old_style_options(const char *fmt, QEMUOptionParameter *list, static int img_create(int argc, char **argv) { int c, ret = 0; +uint64_t img_size = -1; const char *fmt = raw; const char *base_fmt = NULL; const char *filename; @@ -329,6 +330,20 @@ static int img_create(int argc, char **argv) } filename = argv[optind++]; +/* Get image size, if specified */ +if (optind argc) { +ssize_t sval; +sval = strtosz_suffix(argv[optind++], NULL, STRTOSZ_DEFSUFFIX_B); +if (sval 0) { +error(Invalid image size specified! You may use k, M, G or + T suffixes for ); +error(kilobytes, megabytes, gigabytes and terabytes.); +ret = -1; +goto out; +} +img_size = (uint64_t)sval; +} + if (options !strcmp(options, ?)) { ret = print_block_option_help(filename, fmt); goto out; @@ -356,7 +371,8 @@ static int img_create(int argc, char **argv) /* Create parameter list with default values */ param = parse_option_parameters(, create_options, param); -set_option_parameter_int(param, BLOCK_OPT_SIZE, -1); + +set_option_parameter_int(param, BLOCK_OPT_SIZE, img_size); /* Parse -o options */ if (options) { @@ -368,11 +384,6 @@ static int img_create(int argc, char **argv) } } -/* Add size to parameters */ -if (optind argc) { -set_option_parameter(param, BLOCK_OPT_SIZE, argv[optind++]); -} - /* Add old-style options to parameters */ ret = add_old_style_options(fmt, param, base_filename, base_fmt); if (ret 0) { -- 1.7.3.2
Re: [Qemu-devel] IRC channel movement - FreeNode to OFTC
On Wed, Dec 8, 2010 at 23:18, Anthony Liguori anth...@codemonkey.ws wrote: Hi, I'd like to move IRC channels from FreeNode to OFTC, so please join #qemu on OFTC starting now. OFTC is nice place too IMHO... but if it's not a top secret, why move? -- regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com
[Qemu-devel] [PULL] spice: add qxl device, qmp events + monitor commands.
The following changes since commit 138b38b61bf92d4e9588acf934e532499c94e185: ppc: kvm: fix signedness warning (2010-12-08 21:30:19 +0100) are available in the git repository at: git://anongit.freedesktop.org/spice/qemu spice.v23.pull Gerd Hoffmann (7): spice: add qxl vgabios binary. spice: add qxl device spice: connection events. spice: add qmp 'query-spice' and hmp 'info spice' commands. vnc: auth reject cleanup vnc: support password expire vnc/spice: add set_passwd monitor command. Makefile|2 +- Makefile.target |1 + QMP/qmp-events.txt | 64 ++ console.h |1 + hmp-commands.hx | 54 ++ hw/hw.h | 14 + hw/pc.c |8 + hw/qxl-logger.c | 248 hw/qxl-render.c | 226 +++ hw/qxl.c| 1587 +++ hw/qxl.h| 112 hw/vga_int.h|2 +- monitor.c | 130 monitor.h |3 + pc-bios/vgabios-qxl.bin | Bin 0 - 40448 bytes qemu-common.h |3 + qemu-options.hx |6 +- qmp-commands.hx | 127 sysemu.h|3 +- ui/qemu-spice.h |8 + ui/spice-core.c | 261 ui/vnc.c| 44 +- ui/vnc.h|1 + vl.c|4 +- 24 files changed, 2887 insertions(+), 22 deletions(-) create mode 100644 hw/qxl-logger.c create mode 100644 hw/qxl-render.c create mode 100644 hw/qxl.c create mode 100644 hw/qxl.h create mode 100644 pc-bios/vgabios-qxl.bin
[Qemu-devel] [Bug 688085] Re: Guest kernel hang during boot when KVM is active on i386 host
** Changed in: kvm (Ubuntu) Status: New = Invalid ** Changed in: qemu (Ubuntu) Status: New = Invalid ** Changed in: qemu-kvm (Ubuntu) Importance: Undecided = Medium ** Changed in: qemu-kvm (Ubuntu) Status: New = Triaged -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/688085 Title: Guest kernel hang during boot when KVM is active on i386 host Status in QEMU: Fix Released Status in qemu-kvm: Fix Released Status in “kvm” package in Ubuntu: Invalid Status in “qemu” package in Ubuntu: Invalid Status in “qemu-kvm” package in Ubuntu: Triaged Bug description: Binary package hint: qemu Guest kernel hang during boot when KVM is active on i386 host See the patch. http://www.spinics.net/lists/kvm/msg40800.html How to reproduce: 1. install Maversick x86 (not amd64) 2. ensure you have kvm support in processor 3. kvm -kernel /boot/initrd.img-2.6.35-24-generic-pae 4. kvm -no-kvm -kernel /boot/initrd.img-2.6.35-24-generic-pae works OK.
[Qemu-devel] Re: [PATCH] fix qruncom compilation problems
On 12/09/2010 08:16 AM, Paolo Bonzini wrote: On 12/08/2010 10:43 PM, Stefano Bonifazi wrote: Anyway running it with a com file as argument gave the error: mmap: Operation not permitted You have to run it as root I think. Paolo Thank you! Running as root worked, though it raises then the following error (from gdb) I am currently trying to understand: /home/stefano/LinuxDev/qemu-0.12.5/tcg/tcg.c:1367: tcg fatal error Program received signal SIGABRT, Aborted. 0x0012e416 in __kernel_vsyscall () Surely any hint on how to to fix this will be very welcome :) I wish I could understand also what was wrong before, I mean /mmap/.. I understand you can't babysit me, but the gap between what one studies at university and the real world is very big and I feel lost :( I've read pretty much about mmap trying to figure out myself but understanding how to map a file (what I could find in every article about mmap online) is not the same as understanding how it works inside QEMU .. I know each process gets its own logical address space, if I understood fine mmap should take a portion of qruncom address space and give it to the emulator that should then see that as its own address space (please correct me if I am wrong!) .. Now if I got fine the flag MAP_FIXED, obliges the process to give that portion of address space starting at its /addr/ parameter (the first).. or if it is not possible to give an error.. My big doubt is how can the process give exactly that portion of address space starting at zero by just running it as root?.. I am expecting that area of address space to be taken by I dunno, code, data of the process itself.. honestly I don't know how things are allocated when a process is run(and I wish I could learn that).. but how can one think that addresses around zero are free for a mapping?? I'll appreciate very much any explanation, or links where to learn those topics! :) Thank you very much! Best Regards! Stefano B.
[Qemu-devel] Re: IRC channel movement - FreeNode to OFTC
Hi, I'd like to move IRC channels from FreeNode to OFTC, so please join #qemu on OFTC starting now. - what's wrong with freenode ? everyone is there. - #define OFTC ? François.
Re: [Qemu-devel] [PATCH 2/6] [RFC] Emulation of GRLIB IRQMP as defined in GRLIB IP Core User's Manual.
On Thu, Dec 09, 2010 at 12:03:35PM +0100, Fabien Chouteau wrote: On 12/09/2010 11:32 AM, Edgar E. Iglesias wrote: On Mon, Dec 06, 2010 at 10:26:03AM +0100, Fabien Chouteau wrote: Signed-off-by: Fabien Chouteauchout...@adacore.com --- hw/grlib_irqmp.c | 416 ++ 1 files changed, 416 insertions(+), 0 deletions(-) diff --git a/hw/grlib_irqmp.c b/hw/grlib_irqmp.c new file mode 100644 index 000..69e1553 --- /dev/null +++ b/hw/grlib_irqmp.c @@ -0,0 +1,416 @@ +/* + * QEMU GRLIB IRQMP Emulator + * + * (Multiprocessor and extended interrupt not supported) + * + * Copyright (c) 2010 AdaCore + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the Software), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include sysbus.h +#include cpu.h + +#include grlib.h + +/* #define DEBUG_IRQ */ + +#ifdef DEBUG_IRQ +#define DPRINTF(fmt, ...) \ +do { printf(IRQMP: fmt , ## __VA_ARGS__); } while (0) +#else +#define DPRINTF(fmt, ...) +#endif + +#define IRQMP_MAX_CPU 16 +#define IRQMP_REG_SIZE 256 /* Size of memory mapped registers */ + +/* Memory mapped register offsets */ +#define LEVEL_OFFSET 0x00 +#define PENDING_OFFSET 0x04 +#define FORCE0_OFFSET0x08 +#define CLEAR_OFFSET 0x0C +#define MP_STATUS_OFFSET 0x10 +#define BROADCAST_OFFSET 0x14 +#define MASK_OFFSET 0x40 +#define FORCE_OFFSET 0x80 +#define EXTENDED_OFFSET 0xC0 + +typedef struct IRQMP +{ +SysBusDevice busdev; + +CPUSPARCState *env; +} IRQMP; + +typedef struct IRQMPState +{ +uint32_t level; +uint32_t pending; +uint32_t clear; +uint32_t broadcast; + +uint32_t mask[IRQMP_MAX_CPU]; +uint32_t force[IRQMP_MAX_CPU]; +uint32_t extended[IRQMP_MAX_CPU]; + +IRQMP*parent; +} IRQMPState; + +IRQMPState grlib_irqmp_state; + +void grlib_irqmp_set_irq(void *opaque, int irq, int level); + +DeviceState *grlib_irqmp_create(target_phys_addr_t base, +CPUState*env, +qemu_irq **cpu_irqs, +uint32_t nr_irqs) +{ +DeviceState *dev; + +assert(cpu_irqs != NULL); + +dev = qdev_create(NULL, grlib,irqmp); +qdev_prop_set_ptr(dev, cpustate, env); + +if (qdev_init(dev)) { +return NULL; +} + +sysbus_mmio_map(sysbus_from_qdev(dev), 0, base); + +*cpu_irqs = qemu_allocate_irqs(grlib_irqmp_set_irq, +grlib_irqmp_state, + nr_irqs); + +return dev; +} + +static void grlib_irqmp_check_irqs(CPUState *env) +{ +uint32_t pend = 0; +uint32_t level0 = 0; +uint32_t level1 = 0; + +assert(env != NULL); + +/* IRQ for CPU 0 (no SMP support) */ +pend = (grlib_irqmp_state.pending | grlib_irqmp_state.force[0]) + grlib_irqmp_state.mask[0]; + + +level0 = pend ~grlib_irqmp_state.level; +level1 = pend grlib_irqmp_state.level; + +DPRINTF(pend:0x%04x force:0x%04x mask:0x%04x lvl1:0x%04x lvl0:0x%04x\n, +grlib_irqmp_state.pending, grlib_irqmp_state.force[0], +grlib_irqmp_state.mask[0], level1, level0); + +/* Trigger level1 interrupt first and level0 if there is no level1 */ +if (level1 != 0) { +env-pil_in = level1; +} else { +env-pil_in = level0; +} + +if (env-pil_in (env-interrupt_index == 0 || +(env-interrupt_index ~15) == TT_EXTINT)) { +unsigned int i; + +for (i = 15; i 0; i--) { +if (env-pil_in (1 i)) { +int old_interrupt = env-interrupt_index; + +env-interrupt_index
Re: [Qemu-devel] IRC channel movement - FreeNode to OFTC
On 12/09/2010 09:12 AM, Mulyadi Santosa wrote: On Wed, Dec 8, 2010 at 23:18, Anthony Liguorianth...@codemonkey.ws wrote: Hi, I'd like to move IRC channels from FreeNode to OFTC, so please join #qemu on OFTC starting now. OFTC is nice place too IMHO... but if it's not a top secret, why move? Have been meaning to for a while. OFTC is a bit easier to work with than FreeNode. Regards, Anthony Liguori
[Qemu-devel] Re: [PATCH 09/13] ahci: add ahci emulation
Kevin Wolf wrote: Am 09.12.2010 16:48, schrieb Alexander Graf: +static void ncq_cb(void *opaque, int ret) +{ +NCQTransferState *ncq_tfs = (NCQTransferState *)opaque; +IDEState *ide_state; + +if (ret 0) { +/* XXX error */ +} Missing error handling. Yes, that's what the XXX stands for :). I think Stefan wanted to tell us that he thinks this XXX should be addressed. I don't disagree, by the way. ;-) +static void process_ncq_command(AHCIState *s, int port, uint8_t *cmd_fis, +int slot, QEMUSGList *sg) +{ +NCQFrame *ncq_fis = (NCQFrame*)cmd_fis; +uint8_t tag = ncq_fis-tag 3; +NCQTransferState *ncq_tfs = s-dev[port].ncq_tfs[tag]; + +if (ncq_tfs-used) { +/* error - already in use */ +fprintf(stderr, %s: tag %d already used\n, __FUNCTION__, tag); +return; +} + +ncq_tfs-used = 1; +ncq_tfs-drive = s-dev[port]; +ncq_tfs-drive-cmd_fis = cmd_fis; +ncq_tfs-drive-cmd_fis_len = 0x20; +ncq_tfs-slot = slot; +ncq_tfs-lba = ((uint64_t)ncq_fis-lba5 40) | + ((uint64_t)ncq_fis-lba4 32) | + ((uint64_t)ncq_fis-lba3 24) | + ((uint64_t)ncq_fis-lba2 16) | + ((uint64_t)ncq_fis-lba1 8) | + (uint64_t)ncq_fis-lba0; + +/* Note: We calculate the sector count, but don't currently rely on it. + * The total size of the DMA buffer tells us the transfer size instead. */ +ncq_tfs-sector_count = ((uint16_t)ncq_fis-sector_count_high 8) | +ncq_fis-sector_count_low; + +DPRINTF(port, NCQ transfer LBA from %ld to %ld, drive max %ld\n, +ncq_tfs-lba, ncq_tfs-lba + ncq_tfs-sector_count - 2, +s-dev[port].port.ifs[0].nb_sectors - 1); + +ncq_tfs-sglist = *sg; +ncq_tfs-tag = tag; + +switch(ncq_fis-command) { +case READ_FPDMA_QUEUED: +DPRINTF(port, NCQ reading %d sectors from LBA %ld, tag %d\n, +ncq_tfs-sector_count-1, ncq_tfs-lba, ncq_tfs-tag); +ncq_tfs-is_read = 1; + +/* XXX: The specification is unclear about whether the DMA Setup + * FIS here should have the I bit set, but it suggest that it should + * not. Linux works without this interrupt, so I disabled it. + * If someone knows if it is needed, please tell me, or fix this. */ + +/* ahci_trigger_irq(s,s-dev[port],PORT_IRQ_STAT_DSS); */ +DPRINTF(port, tag %d aio read %ld\n, ncq_tfs-tag, ncq_tfs-lba); +dma_bdrv_read(ncq_tfs-drive-port.ifs[0].bs, ncq_tfs-sglist, + ncq_tfs-lba, ncq_cb, ncq_tfs); +break; +case WRITE_FPDMA_QUEUED: +DPRINTF(port, NCQ writing %d sectors to LBA %ld, tag %d\n, +ncq_tfs-sector_count-1, ncq_tfs-lba, ncq_tfs-tag); +ncq_tfs-is_read = 0; +/* ahci_trigger_irq(s,s-dev[port],PORT_IRQ_STAT_DSS); */ +DPRINTF(port, tag %d aio write %ld\n, ncq_tfs-tag, ncq_tfs-lba); +dma_bdrv_write(ncq_tfs-drive-port.ifs[0].bs, ncq_tfs-sglist, + ncq_tfs-lba, ncq_cb, ncq_tfs); +break; +default: +hw_error(ahci: tried to process non-NCQ command as NCQ\n); Guest triggerable abort. Those happen. The guest can shoot itself in the foot. We have more of these in other places. Just check virtio.c and search for abort() :). They are bugs which should be fixed in virtio rather than being spread to new code. Not sure about that. Would you prefer a broken guest to abort so you can debug it or to have it spew your log files with error messages or to silently ignore errors and never find bugs? Alex
[Qemu-devel] Re: [PATCH v5 0/2] Clean up img_create() and introduce strtosz_suffix()
Am 09.12.2010 14:17, schrieb jes.soren...@redhat.com: From: Jes Sorensen jes.soren...@redhat.com This patch set introduces strtosz_suffix() which is needed to be able to use strtosz parsing with a non MB default suffix. This is used to clean up qemu-img.c:img_create(). Kevin asked me to rebase this instead of applying the other patches on top, so please discard the previous versions. Sorry for the patch noise. v5 fixes the two issues pointed out by Stefan, making the call in strtosz() explicitly use STRTOSZ_DEFSUFFIX_MB instead of 0 to specify the default and adds a named argument to the prototype for strtosz_suffix(). Jes Sorensen (2): Introduce strtosz_suffix() qemu-img.c: Clean up handling of image size in img_create() cutils.c | 17 ++--- qemu-common.h |7 +++ qemu-img.c| 23 +-- 3 files changed, 38 insertions(+), 9 deletions(-) Thanks, applied all to the block branch. Kevin
[Qemu-devel] [PATCH 13/14] qemu-img: Free option parameter lists in img_create()
From: Stefan Hajnoczi stefa...@linux.vnet.ibm.com Free option parameter lists in the img_create() error return path. Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com Signed-off-by: Kevin Wolf kw...@redhat.com --- qemu-img.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index d146d8c..c5a173c 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -428,8 +428,6 @@ static int img_create(int argc, char **argv) puts(); ret = bdrv_create(drv, filename, param); -free_option_parameters(create_options); -free_option_parameters(param); if (ret 0) { if (ret == -ENOTSUP) { @@ -441,6 +439,8 @@ static int img_create(int argc, char **argv) } } out: +free_option_parameters(create_options); +free_option_parameters(param); if (ret) { return 1; } -- 1.7.2.3
[Qemu-devel] [PATCH v5 0/2] Clean up img_create() and introduce strtosz_suffix()
From: Jes Sorensen jes.soren...@redhat.com This patch set introduces strtosz_suffix() which is needed to be able to use strtosz parsing with a non MB default suffix. This is used to clean up qemu-img.c:img_create(). Kevin asked me to rebase this instead of applying the other patches on top, so please discard the previous versions. Sorry for the patch noise. v5 fixes the two issues pointed out by Stefan, making the call in strtosz() explicitly use STRTOSZ_DEFSUFFIX_MB instead of 0 to specify the default and adds a named argument to the prototype for strtosz_suffix(). Jes Sorensen (2): Introduce strtosz_suffix() qemu-img.c: Clean up handling of image size in img_create() cutils.c | 17 ++--- qemu-common.h |7 +++ qemu-img.c| 23 +-- 3 files changed, 38 insertions(+), 9 deletions(-) -- 1.7.3.2
[Qemu-devel] Re: [PATCH 1/2] Introduce strtosz_suffix()
On 12/09/10 13:53, Stefan Hajnoczi wrote: On Thu, Dec 09, 2010 at 01:13:33PM +0100, jes.soren...@redhat.com wrote: @@ -371,3 +377,8 @@ fail: return retval; } + +ssize_t strtosz(const char *nptr, char **end) +{ +return strtosz_suffix(nptr, end, 0); This obscures what the default is, please use STRTOSZ_DEFSUFFIX_MB. 0 isn't very meaningful and requires the reader to dig into strtosz(). It doesn't make much different to me, but ok, that is easy to fix. diff --git a/qemu-common.h b/qemu-common.h index de82c2e..dc44cd6 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -149,7 +149,14 @@ time_t mktimegm(struct tm *tm); int qemu_fls(int i); int qemu_fdatasync(int fd); int fcntl_setfl(int fd, int flag); + +#define STRTOSZ_DEFSUFFIX_TB'T' +#define STRTOSZ_DEFSUFFIX_GB'G' +#define STRTOSZ_DEFSUFFIX_MB'M' +#define STRTOSZ_DEFSUFFIX_KB'K' +#define STRTOSZ_DEFSUFFIX_B 'B' ssize_t strtosz(const char *nptr, char **end); +ssize_t strtosz_suffix(const char *nptr, char **end, const char); An argument name would be nice: const char unit? I'll add that in the same round. Cheers, Jes
[Qemu-devel] [PATCH 1/2] Introduce strtosz_suffix()
From: Jes Sorensen jes.soren...@redhat.com This introduces strtosz_suffix() which allows the caller to specify a default suffix in case the non default of MB is wanted. strtosz() is kept as a wrapper for strtosz_suffix() which keeps it's current default of MB. Signed-off-by: Jes Sorensen jes.soren...@redhat.com --- cutils.c | 17 ++--- qemu-common.h |7 +++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/cutils.c b/cutils.c index 28089aa..7984bc1 100644 --- a/cutils.c +++ b/cutils.c @@ -291,10 +291,10 @@ int fcntl_setfl(int fd, int flag) * value must be terminated by whitespace, ',' or '\0'. Return -1 on * error. */ -ssize_t strtosz(const char *nptr, char **end) +ssize_t strtosz_suffix(const char *nptr, char **end, const char default_suffix) { ssize_t retval = -1; -char *endptr, c; +char *endptr, c, d; int mul_required = 0; double val, mul, integral, fraction; @@ -313,10 +313,16 @@ ssize_t strtosz(const char *nptr, char **end) * part of a multi token argument. */ c = *endptr; +d = c; if (isspace(c) || c == '\0' || c == ',') { c = 0; +if (default_suffix) { +d = default_suffix; +} else { +d = c; +} } -switch (c) { +switch (d) { case 'B': case 'b': mul = 1; @@ -371,3 +377,8 @@ fail: return retval; } + +ssize_t strtosz(const char *nptr, char **end) +{ +return strtosz_suffix(nptr, end, STRTOSZ_DEFSUFFIX_MB); +} diff --git a/qemu-common.h b/qemu-common.h index de82c2e..1ed32e5 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -149,7 +149,14 @@ time_t mktimegm(struct tm *tm); int qemu_fls(int i); int qemu_fdatasync(int fd); int fcntl_setfl(int fd, int flag); + +#define STRTOSZ_DEFSUFFIX_TB 'T' +#define STRTOSZ_DEFSUFFIX_GB 'G' +#define STRTOSZ_DEFSUFFIX_MB 'M' +#define STRTOSZ_DEFSUFFIX_KB 'K' +#define STRTOSZ_DEFSUFFIX_B'B' ssize_t strtosz(const char *nptr, char **end); +ssize_t strtosz_suffix(const char *nptr, char **end, const char default_suffix); /* path.c */ void init_paths(const char *prefix); -- 1.7.3.2
[Qemu-devel] [Bug 688052] [NEW] usb does not work 0.13.0
Public bug reported: Hi all, I'm using both, debian lenny and debian squeeze. I installed qemu-kvm (0.12.5) form debian repository but I got problem trying to pass a host usb device to the guest. I compiled so the latest stable version (0.13.0) hoping that the problem was fixed. It didn't help, the error I get is always: usb_create: no bus specified, using usb.0 for usb-host The command I use is qemu-system-x86_64 -hda lenny_amd64_vergine.qcow2 -usbdevice host:002.007 -boot order=c On internet I found this, it might help: http://www.mail-archive.com/qemu-devel@nongnu.org/msg38795.html The guest is a simple debian lenny with 2.6.26 kernel. I tried also to download the qemu development version but the download get interruped git clone http://git.qemu.org/qemu.git Cloning into qemu... error: Failed connect to git.qemu.org:80; No such file or directory (curl_result = 7, http_code = 0, sha1 = 62d76a25fe741bdaf1157f0edaf50a7772541db6) error: Unable to find 62d76a25fe741bdaf1157f0edaf50a7772541db6 under http://git.qemu.org/qemu.git I attach more info about the host machine I'm testing on. ** Affects: qemu Importance: Undecided Status: New ** Tags: usb -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/688052 Title: usb does not work 0.13.0 Status in QEMU: New Bug description: Hi all, I'm using both, debian lenny and debian squeeze. I installed qemu-kvm (0.12.5) form debian repository but I got problem trying to pass a host usb device to the guest. I compiled so the latest stable version (0.13.0) hoping that the problem was fixed. It didn't help, the error I get is always: usb_create: no bus specified, using usb.0 for usb-host The command I use is qemu-system-x86_64 -hda lenny_amd64_vergine.qcow2 -usbdevice host:002.007 -boot order=c On internet I found this, it might help: http://www.mail-archive.com/qemu-devel@nongnu.org/msg38795.html The guest is a simple debian lenny with 2.6.26 kernel. I tried also to download the qemu development version but the download get interruped git clone http://git.qemu.org/qemu.git Cloning into qemu... error: Failed connect to git.qemu.org:80; No such file or directory (curl_result = 7, http_code = 0, sha1 = 62d76a25fe741bdaf1157f0edaf50a7772541db6) error: Unable to find 62d76a25fe741bdaf1157f0edaf50a7772541db6 under http://git.qemu.org/qemu.git I attach more info about the host machine I'm testing on.
[Qemu-devel] [Bug 688052] Re: usb does not work 0.13.0
** Attachment added: host hardware details https://bugs.launchpad.net/bugs/688052/+attachment/1760810/+files/host_info.txt.gz -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/688052 Title: usb does not work 0.13.0 Status in QEMU: New Bug description: Hi all, I'm using both, debian lenny and debian squeeze. I installed qemu-kvm (0.12.5) form debian repository but I got problem trying to pass a host usb device to the guest. I compiled so the latest stable version (0.13.0) hoping that the problem was fixed. It didn't help, the error I get is always: usb_create: no bus specified, using usb.0 for usb-host The command I use is qemu-system-x86_64 -hda lenny_amd64_vergine.qcow2 -usbdevice host:002.007 -boot order=c On internet I found this, it might help: http://www.mail-archive.com/qemu-devel@nongnu.org/msg38795.html The guest is a simple debian lenny with 2.6.26 kernel. I tried also to download the qemu development version but the download get interruped git clone http://git.qemu.org/qemu.git Cloning into qemu... error: Failed connect to git.qemu.org:80; No such file or directory (curl_result = 7, http_code = 0, sha1 = 62d76a25fe741bdaf1157f0edaf50a7772541db6) error: Unable to find 62d76a25fe741bdaf1157f0edaf50a7772541db6 under http://git.qemu.org/qemu.git I attach more info about the host machine I'm testing on.
[Qemu-devel] Re: [PATCH v2] block: Introduce path_has_protocol() function
Am 09.12.2010 12:53, schrieb Stefan Hajnoczi: The bdrv_find_protocol() function returns NULL if an unknown protocol name is given. It returns the file protocol when the filename contains no protocol at all. This makes it difficult to distinguish between paths which contain a protocol and those which do not. Factor out a helper function that tests whether or not a filename has a protocol. The next patch makes use of this function. Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com --- Sorry for this oversight, Windows breakage fixed. v2: * Define Windows drive functions before path_has_protocol() Thanks, applied to the block branch. Kevin
[Qemu-devel] Re: [PATCH 2/6] qemu, qmp: convert do_inject_nmi() to QObject
On Thu, 09 Dec 2010 14:59:00 +0800 Lai Jiangshan la...@cn.fujitsu.com wrote: Convert do_inject_nmi() to QObject, we need to use it(via libvirt). Patches 0/6 and 1/6 are missing. Also, I see that you're converting two unrelated commands in the same series. Please, split into two series. It is trivial, as it never fails, doesn't have output nor return any data. It does fail: the cpu index might be invalid. Also, does this depend on the guest ability to respond in some way? Furthermore, it's missing documentation, please read the 'Development Process' section from QMP's readme file: http://git.qemu.org/qemu.git/tree/QMP/README A last comment is that, maybe we should call it inject-nmi or even inject-non-maskable-interrupt. Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- diff --git a/hmp-commands.hx b/hmp-commands.hx index 7a49b74..2e6b034 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -725,7 +725,8 @@ ETEXI .args_type = cpu_index:i, .params = cpu, .help = inject an NMI on the given CPU, -.mhandler.cmd = do_inject_nmi, +.user_print = monitor_user_noop, +.mhandler.cmd_new = do_inject_nmi, }, #endif STEXI diff --git a/monitor.c b/monitor.c index 729a7cb..1f0d29e 100644 --- a/monitor.c +++ b/monitor.c @@ -2120,7 +2120,7 @@ static void do_wav_capture(Monitor *mon, const QDict *qdict) #endif #if defined(TARGET_I386) -static void do_inject_nmi(Monitor *mon, const QDict *qdict) +static int do_inject_nmi(Monitor *mon, const QDict *qdict, QObject **ret_data) { CPUState *env; int cpu_index = qdict_get_int(qdict, cpu_index); @@ -2130,6 +2130,7 @@ static void do_inject_nmi(Monitor *mon, const QDict *qdict) cpu_interrupt(env, CPU_INTERRUPT_NMI); break; } +return 0; } #endif diff --git a/qmp-commands.hx b/qmp-commands.hx index a385b66..2506981 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -453,6 +453,22 @@ Example: EQMP +#if defined(TARGET_I386) +{ +.name = nmi, +.args_type = cpu_index:i, +.params = cpu, +.help = inject an NMI on the given CPU, +.user_print = monitor_user_noop, +.mhandler.cmd_new = do_inject_nmi, +}, +#endif +SQMP +...@item nmi @var{cpu} +...@findex nmi +Inject an NMI on the given CPU (x86 only). +EQMP + { .name = migrate, .args_type = detach:-d,blk:-b,inc:-i,uri:s,