Re: [Qemu-devel] broken incoming migration

2013-06-05 Thread Peter Lieven

Am 05.06.2013 um 05:37 schrieb Alexey Kardashevskiy a...@ozlabs.ru:

 On 06/05/2013 05:15 AM, Peter Lieven wrote:
 
 Am 04.06.2013 um 17:17 schrieb Paolo Bonzini pbonz...@redhat.com:
 
 Il 04/06/2013 16:48, Peter Lieven ha scritto:
 Still using 3.2, but strange enough the above example is also not
 increasing RSS size for me.
 
 Can you try the following:
 qemu git master with 1G of memory (hanging in bios with no boot device)
 and migrate it. Before migration RSS Size os somewhat
 around 16MB. After migration its RSS size is in the order of 1G.
 
 That may be a kernel bug.  The kernel did not do the copy-on-write trick
 on huge zero pages.  It was fixed last year, maybe 3.2 is not enough.
 Try adding a MADV_HUGEPAGE madvise to the testcase and see if it reproduces.
 
 that's it. thanks for the pointer. the huge zero page was introduced in 3.8.
 
 paolo, alexey: can you please verify the following works for you:
 https://github.com/plieven/qemu/tree/fix-migration
 
 These two?
 848b796 Tue Jun 4 14:43:04 2013 +0200 Peter Lieven migration: do not
 overwrite zero pages
 2206ac8 Tue Jun 4 14:25:33 2013 +0200 Peter Lieven Revert migration: do
 not sent zero pages in bulk stage

Yes, sorry forgot to mention this.

 
 That works for me (qemu 1.5, kernel 3.9-rc2).
 Tested-by: Alexey Kardashevskiy a...@ozlabs.ru

Thank you,
Peter


Re: [Qemu-devel] [snabb-devel:327] Re: snabbswitch integration with QEMU for userspace ethernet I/O

2013-06-05 Thread Luke Gorrie
On 4 June 2013 14:56, Michael S. Tsirkin m...@redhat.com wrote:

 That would mean making snabb switch part of QEMU.


Just curious - not suggesting that this is practical - but what would that
mean?

Is the important thing to keep all device implementations in the same
source tree so that QEMU developers can take responsibility for everything
working?

Or is it that the Snabb Switch code would need to execute inside the QEMU
process at runtime?

Snabb Switch is actually reasonably embeddable: less than 1MB, single
threaded, hardly makes any system calls. The one big dependency we have
is LuaJIT (luajit.org) but that is routinely embedded in video games and
such like.


[Qemu-devel] [PATCH] virtio-net: fix wrong size of vlan filter table

2013-06-05 Thread Amos Kong
The MAX_VLAN is 4096, currently the vlan filter table has 512
(4096  3) entries, it's wrong.

One entry in vlan filter table can indicate 32(1  5) vlans,
so the table should have 128 (4096  5) entries.

Signed-off-by: Amos Kong ak...@redhat.com
---
btw, it would be simple to use an uint32 number to indicate
all vlans (same as igbvf). I found e1000 uses the same table.
Nothing needs to change here, it would cause migration issue.
---
 hw/net/virtio-net.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index d4ef21f..6dedb97 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -293,7 +293,7 @@ static void virtio_net_reset(VirtIODevice *vdev)
 n-mac_table.uni_overflow = 0;
 memset(n-mac_table.macs, 0, MAC_TABLE_ENTRIES * ETH_ALEN);
 memcpy(n-mac[0], n-nic-conf-macaddr, sizeof(n-mac));
-memset(n-vlans, 0, MAX_VLAN  3);
+memset(n-vlans, 0, MAX_VLAN  5);
 }
 
 static void peer_test_vnet_hdr(VirtIONet *n)
@@ -1246,7 +1246,7 @@ static void virtio_net_save(QEMUFile *f, void *opaque)
 qemu_put_byte(f, n-allmulti);
 qemu_put_be32(f, n-mac_table.in_use);
 qemu_put_buffer(f, n-mac_table.macs, n-mac_table.in_use * ETH_ALEN);
-qemu_put_buffer(f, (uint8_t *)n-vlans, MAX_VLAN  3);
+qemu_put_buffer(f, (uint8_t *)n-vlans, MAX_VLAN  5);
 qemu_put_be32(f, n-has_vnet_hdr);
 qemu_put_byte(f, n-mac_table.multi_overflow);
 qemu_put_byte(f, n-mac_table.uni_overflow);
@@ -1316,7 +1316,7 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int 
version_id)
 }
  
 if (version_id = 6)
-qemu_get_buffer(f, (uint8_t *)n-vlans, MAX_VLAN  3);
+qemu_get_buffer(f, (uint8_t *)n-vlans, MAX_VLAN  5);
 
 if (version_id = 7) {
 if (qemu_get_be32(f)  !peer_has_vnet_hdr(n)) {
-- 
1.8.1.4




Re: [Qemu-devel] [PATCH] blockdev: reset werror/rerror on drive_del

2013-06-05 Thread Markus Armbruster
Eric Blake ebl...@redhat.com writes:

 On 06/04/2013 01:24 PM, Markus Armbruster wrote:
 Paolo Bonzini pbonz...@redhat.com writes:
 
 Il 04/06/2013 18:37, Markus Armbruster ha scritto:
 I figure the bit that can't be resolved now is letting the user switch
 off stop on error safely before a drive_del.  Even if we had a command
 for that, there'd still be a window between that command's execution and
 drive_del's.  Your patch solves the problem by having drive_del switch
 it off unconditionally.  Oookay, but please document it, because it's
 not exactly obvious.

 It is not obvious, but it is not surprising either when you see it (i.e.
 you won't really be surprised by the errors in the guest and won't need
 to know that, under the hood, rerror has been changed from the value you
 specified).


 This is drive_add's documentation in hmp-commands.hx:
 
 Remove host block device.  The result is that guest generated IO is
 no longer submitted against the host device underlying the disk.
 Once a drive has been deleted, the QEMU Block layer returns -EIO
 which results in IO errors in the guest for applications that are
 reading/writing to the device.
 
 Suggest to add:
 
 These errors are always reported to the guest, regardless of the
 drive's error actions (drive options rerror, werror).
 
 Independently, libvirt needs fixing.

 Total agreement that libvirt needs to use a saner disk hot-unplug
 sequence when it is known that qemu provides one.  I've filed
 https://bugzilla.redhat.com/show_bug.cgi?id=970761
 to remind us to fix libvirt.

Sane sequence

1. device_del

2. Wait for DEVICE_DELETED

3. if timeout, drive_del

Might make sense to offer a choice in the API between fail and
destroy the block device if guest doesn't cooperate.



Re: [Qemu-devel] [PATCH v2 2/2] net: introduce command to query mac-table information

2013-06-05 Thread Amos Kong
On Wed, May 29, 2013 at 01:31:12PM +0800, Jason Wang wrote:
 On 05/16/2013 07:07 PM, Amos Kong wrote:
  We want to implement mac programming over macvtap through Libvirt.
  The previous patch adds QMP event to notify management of mac-table
  change. This patch adds a monitor command to query rx mode information
  of mac-tables.
 
  (qemu) info mac-table vnet0
  vnet0:
   \ promisc: on
   \ allmulti: off
   \ alluni: off
   \ nomulti: off
   \ nouni: off
   \ nobcast: off
   \ multi_overflow: off
   \ uni_overflow: off
   \ multicast:
  01:00:5e:00:00:01
  33:33:00:00:00:01
  33:33:ff:12:34:56
 
  Signed-off-by: Amos Kong ak...@redhat.com
 
 Maybe you also need a command to query the vlan table, or rename the
 command as info filter and do it here.

Thanks for your reminder.

Yes, we need to include all filters that are used in receive_filter().
It contains main-mac, rx-mode items(mac-table, promisc, unit/multi/broadcast
flags), vlan-table.

It's not good to return all(128) entries of vlan-table to monitor client,
and management only use QMP to query info, so I will drop HMP command.


Amos.



Re: [Qemu-devel] [PATCH] virtio-net: fix wrong size of vlan filter table

2013-06-05 Thread Amos Kong
On Wed, Jun 05, 2013 at 02:13:48PM +0800, Amos Kong wrote:
 The MAX_VLAN is 4096, currently the vlan filter table has 512
 (4096  3) entries, it's wrong.
 
 One entry in vlan filter table can indicate 32(1  5) vlans,
 so the table should have 128 (4096  5) entries.
 
 Signed-off-by: Amos Kong ak...@redhat.com
 ---

This patch breaks the migration.

 btw, it would be simple to use an uint32 number to indicate
 all vlans (same as igbvf). I found e1000 uses the same table.
 Nothing needs to change here, it would cause migration issue.

The comment is wrong, igbvf also uses an array.

Will post a v2 with migration fix.

 ---
  hw/net/virtio-net.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
 

-- 
Amos.



Re: [Qemu-devel] VM can not boot after commit 235e898

2013-06-05 Thread Dunrong Huang
On Wed, Jun 5, 2013 at 10:44 AM, Dunrong Huang riegama...@gmail.com wrote:



 On Wed, Jun 5, 2013 at 1:03 AM, Jordan Justen jljus...@gmail.com wrote:

 On Tue, Jun 4, 2013 at 1:26 AM, Dunrong Huang riegama...@gmail.com
 wrote:
  On Tue, Jun 4, 2013 at 3:51 PM, Gleb Natapov g...@redhat.com wrote:
  On Tue, Jun 04, 2013 at 03:47:47PM +0800, Dunrong Huang wrote:
   On Tue, Jun 4, 2013 at 2:47 PM, Paolo Bonzini pbonz...@redhat.com
   wrote:
  
Il 04/06/2013 05:47, Dunrong Huang ha scritto:

 QEMU command:
 ~/usr/bin/qemu-system-x86_64 -enable-kvm -m 1024
 debian-append.img

 git bisect tells that the following commit causes this bug:

 commit 235e8982ad393e5611cb892df54881c872eea9e1
 Author: Jordan Justen jordan.l.jus...@intel.com
 mailto:jordan.l.jus...@intel.com
 Date:   Wed May 29 01:27:26 2013 -0700

 kvm: support using KVM_MEM_READONLY flag for regions

 For readonly memory regions and rom devices in romd_mode,
 we make use of the KVM_MEM_READONLY. A slot that uses
 KVM_MEM_READONLY can be read from and code can execute from
 the
 region, but writes will exit to qemu.

 After reverting this commit, VM can boot normally.
   
A patch is queued for that.  Using kernel 3.8 or reverting the
 commit
will both work.
   
   Ok, thanks for information, I will try it.
  
  The fix is 651eb0f4 and you claim it is still fails for you. This is
  strange because the commit fixed the problem for everyone else. Can you
  double check that you are testing the right commit and you recompiled
  and reinstalled?
 
 
  I am sure 651eb0f4 does not fix this problem.
 
  My test environment is below:
 
  * config.log:
  # head -n 2 config.log
  # QEMU configure log 2013年 06月 04日 星期二 16:12:59 CST
  # Configured with: './configure' '--prefix=/root/usr' '--enable-kvm'
  '--enable-werror' '--enable-debug' '--enable-debug-tcg'
  '--enable-debug-info' '--enable-sdl' '--enable-gtk' '--enable-virtfs'
  '--enable-vnc' '--enable-mixemu' '--enable-vnc-tls' '--enable-vnc-sasl'
  '--enable-vnc-jpeg' '--enable-vnc-png' '--enable-vnc-ws'
 '--enable-curses'
  '--enable-curl' '--enable-nptl' '--enable-system' '--enable-user'
  '--enable-linux-user' '--enable-guest-base' '--enable-uuid'
 '--enable-vde'
  '--enable-linux-aio' '--enable-cap-ng' '--enable-attr' '--enable-docs'
  '--enable-vhost-net' '--enable-spice' '--enable-usb-redir'
  '--enable-smartcard-nss' '--enable-tpm' '--enable-guest-agent'
  '--target-list=x86_64-softmmu'
 
  * kernel version:
  # uname -a
  Linux gentoo-company 3.8.2-gentoo #1 SMP Fri Mar 8 11:44:36 CST 2013
 x86_64
  Intel(R) Core(TM)2 Duo CPU E7500 @ 2.93GHz GenuineIntel GNU/Linux

 You were using a 3.8 kernel originally? (Someone mentioned trying a
 3.8 kernel, and I think that is when you went to 3.8.)

 yes, I have been using kernel 3.8.2 lately, not because of Paolo's
 suggestion.

   * details of git tree:
  # git log HEAD --oneline
  1713924 gtk: don't use g_object_unref on GdkCursor
  41686a9 gtk: don't resize window when enabling scaling
  651eb0f fix double free the memslot in kvm_set_phys_mem
  25b4833 configure: Report unknown target names more helpfully
  6e92f82 configure: Autogenerate default target list
  0ded1fe Merge remote-tracking branch 'pmaydell/arm-devs.next' into
 staging
  95669e6 i.MX: Improve EPIT timer code.
  6539ed2 exynos4210.c: register rom_mem for memory migration
 
 
  * QEMU command line:
  x86_64-softmmu/qemu-system-x86_64 -enable-kvm -cdrom
  /mnt/nfs/Images/ISO/ubuntu-12.04-dvd-amd64.iso

 FWIW, I've been able to boot the 11.10 iso when booted to a 3.9 kernel.

 Does it only fail after you boot the OS? If you just run KVM without a
 disk, so only seabios runs, is it okay?


 It fails even runing without any parameters, like:
 x86_64-softmmu/qemu-system-x86_64 -enable-kvm

 No BIOS information printed, just a black screen is shown.


  After disable KVM_MEM_READONLY flag like below, VM can boot normally.
  diff --git a/kvm-all.c b/kvm-all.c
  index 405480e..c33ba6e 100644
  --- a/kvm-all.c
  +++ b/kvm-all.c
  @@ -774,7 +774,7 @@ static void kvm_set_phys_mem(MemoryRegionSection
  *section, bool add)
   mem-memory_size = size;
   mem-start_addr = start_addr;
   mem-ram = ram;
  -mem-flags = kvm_mem_flags(s, log_dirty, readonly_flag);
  +mem-flags = kvm_mem_flags(s, log_dirty, false);
 
   err = kvm_set_user_memory_region(s, mem);
   if (err) {
 
  I can provide more details if needed.

 I don't think you mentioned how it fails. Does KVM crash? Is an error
 message printed? Does the VM reset, or just hang?


 No QEMU or kvm crashes, no error message printed, I mean it just hangs,
 even no BIOS information are printed.
 And top shows QEMU consumes 100% cpu.

 When I define DEBUG_KVM in kvm-all.c, and run QEMU(this time I boot a
 normal OS disk),
 # x86_64-softmmu/qemu-system-x86_64 -enable-kvm -hda
 /mnt/nfs/Images/debian-append.img
 kvm_init_vcpu
 

[Qemu-devel] [PATCH] pseries: Support for in-kernel XICS interrupt controller

2013-06-05 Thread Alexey Kardashevskiy
From: David Gibson da...@gibson.dropbear.id.au

Recent (host) kernels support emulating the PAPR defined XICS interrupt
controller system within KVM.  This patch allows qemu to initialize and
configure the in-kernel XICS, and keep its state in sync with qemu's XICS
state as necessary.

This should give considerable performance improvements.  e.g. on a simple
IPI ping-pong test between hardware threads, using qemu XICS gives us
around 5,000 irqs/second, whereas the in-kernel XICS gives us around
70,000 irqs/s on the same hardware configuration.

[Mike Qiu qiud...@linux.vnet.ibm.com: fixed mistype which caused 
ics_set_kvm_state() to fail]
Signed-off-by: David Gibson da...@gibson.dropbear.id.au
Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru
---

This depends on the pseries: savevm support for XICS interrupt controller
patch posted earlier.

---
 hw/ppc/spapr.c|4 +-
 hw/ppc/xics.c |  333 -
 include/hw/ppc/xics.h |8 +-
 3 files changed, 336 insertions(+), 9 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 71da11b..04e0eae 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1136,8 +1136,6 @@ static void ppc_spapr_init(QEMUMachineInitArgs *args)
 }
 env = cpu-env;
 
-xics_cpu_setup(spapr-icp, cpu);
-
 /* Set time-base frequency to 512 MHz */
 cpu_ppc_tb_init(env, TIMEBASE_FREQ);
 
@@ -1151,6 +1149,8 @@ static void ppc_spapr_init(QEMUMachineInitArgs *args)
 kvmppc_set_papr(cpu);
 }
 
+xics_cpu_setup(spapr-icp, cpu);
+
 qemu_register_reset(spapr_cpu_reset, cpu);
 }
 
diff --git a/hw/ppc/xics.c b/hw/ppc/xics.c
index 02e44a0..b83f19f 100644
--- a/hw/ppc/xics.c
+++ b/hw/ppc/xics.c
@@ -29,12 +29,19 @@
 #include trace.h
 #include hw/ppc/spapr.h
 #include hw/ppc/xics.h
+#include kvm_ppc.h
+#include sysemu/kvm.h
+#include config.h
+#include qemu/config-file.h
+
+#include sys/ioctl.h
 
 /*
  * ICP: Presentation layer
  */
 
 struct icp_server_state {
+CPUState *cs;
 uint32_t xirr;
 uint8_t pending_priority;
 uint8_t mfrr;
@@ -53,6 +60,9 @@ struct icp_state {
 uint32_t nr_servers;
 struct icp_server_state *ss;
 struct ics_state *ics;
+uint32_t set_xive_token, get_xive_token,
+int_off_token, int_on_token;
+int kernel_xics_fd;
 };
 
 static void ics_reject(struct ics_state *ics, int nr);
@@ -168,6 +178,66 @@ static void icp_irq(struct icp_state *icp, int server, int 
nr, uint8_t priority)
 }
 }
 
+static void icp_get_kvm_state(struct icp_server_state *ss)
+{
+#ifdef CONFIG_KVM
+uint64_t state;
+struct kvm_one_reg reg = {
+.id = KVM_REG_PPC_ICP_STATE,
+.addr = (uintptr_t)state,
+};
+int ret;
+
+if (!ss-cs) {
+return; /* kernel irqchip not in use */
+}
+
+ret = kvm_vcpu_ioctl(ss-cs, KVM_GET_ONE_REG, reg);
+if (ret != 0) {
+fprintf(stderr, Unable to retrieve KVM interrupt controller state
+ for CPU %d: %s\n, ss-cs-cpu_index, strerror(errno));
+exit(1);
+}
+
+ss-xirr = state  KVM_REG_PPC_ICP_XISR_SHIFT;
+ss-mfrr = (state  KVM_REG_PPC_ICP_MFRR_SHIFT)
+ KVM_REG_PPC_ICP_MFRR_MASK;
+ss-pending_priority = (state  KVM_REG_PPC_ICP_PPRI_SHIFT)
+ KVM_REG_PPC_ICP_PPRI_MASK;
+#endif /* CONFIG_KVM */
+}
+
+static int icp_set_kvm_state(struct icp_server_state *ss)
+{
+#ifdef CONFIG_KVM
+uint64_t state;
+struct kvm_one_reg reg = {
+.id = KVM_REG_PPC_ICP_STATE,
+.addr = (uintptr_t)state,
+};
+int ret;
+
+if (!ss-cs) {
+return 0; /* kernel irqchip not in use */
+}
+
+state = ((uint64_t)ss-xirr  KVM_REG_PPC_ICP_XISR_SHIFT)
+| ((uint64_t)ss-mfrr  KVM_REG_PPC_ICP_MFRR_SHIFT)
+| ((uint64_t)ss-pending_priority  KVM_REG_PPC_ICP_PPRI_SHIFT);
+
+ret = kvm_vcpu_ioctl(ss-cs, KVM_SET_ONE_REG, reg);
+if (ret != 0) {
+fprintf(stderr, Unable to restore KVM interrupt controller state (0x%
+PRIx64 ) for CPU %d: %s\n, state, ss-cs-cpu_index,
+strerror(errno));
+exit(1);
+return ret;
+}
+#endif /* CONFIG_KVM */
+
+return 0;
+}
+
 /*
  * ICS: Source layer
  */
@@ -336,6 +406,107 @@ static void ics_eoi(struct ics_state *ics, int nr)
 }
 }
 
+static void ics_get_kvm_state(struct ics_state *ics)
+{
+#ifdef CONFIG_KVM
+uint64_t state;
+struct kvm_device_attr attr = {
+.flags = 0,
+.group = KVM_DEV_XICS_GRP_SOURCES,
+.addr = (uint64_t)(uintptr_t)state,
+};
+int i;
+
+if (ics-icp-kernel_xics_fd == -1) {
+return; /* kernel irqchip not in use */
+}
+
+for (i = 0; i  ics-nr_irqs; i++) {
+struct ics_irq_state *irq = ics-irqs[i];
+int ret;
+
+attr.attr = i + ics-offset;
+
+ret = ioctl(ics-icp-kernel_xics_fd, KVM_GET_DEVICE_ATTR, attr);
+if (ret != 0) {
+fprintf(stderr, Unable to retrieve 

Re: [Qemu-devel] [PATCH 00/13 v2] pseries: savevm / migration support

2013-06-05 Thread Alexey Kardashevskiy
On 06/05/2013 11:59 AM, Alexey Kardashevskiy wrote:
 On 06/04/2013 10:42 PM, Andreas Färber wrote:
 Am 04.06.2013 14:20, schrieb Alexey Kardashevskiy:
 I still have to learn how to force git not to overwrite the original commit 
 author :-/
 Is there any way to tell the original creator in the commit message so it 
 could live
 in a git forever and survive commit changes?

 To fix it up:

 git commit --amend --author=Foo Bar foo@bar
 
 Then I have to recall about every patch whether it is mine or not. Annoying :(

Sorry for my ignorance, figured it all out now. git rather rules :)



-- 
Alexey



Re: [Qemu-devel] [PATCH 11/39] msix: split msix_free from msix_uninit

2013-06-05 Thread Paolo Bonzini
Il 05/06/2013 06:53, Michael S. Tsirkin ha scritto:
 On Wed, Jun 05, 2013 at 12:40:00AM +0200, Paolo Bonzini wrote:
 Il 05/06/2013 00:03, Michael S. Tsirkin ha scritto:
 +if (dev-msix_table || dev-msix_pba || dev-msix_entry_used) {
 +msix_free(dev);
 +}
 +
  dev-msix_table = g_malloc0(table_size);
  dev-msix_pba = g_malloc0(pba_size);
  dev-msix_entry_used = g_malloc0(nentries * sizeof 
 *dev-msix_entry_used);
 Wow msix_init calls msix_free, and not on error path?
 What's going on here?

 I wasn't too sure that you could get here only with NULL
 msix_table/pba/entry_used and wanted to protect against leaks.  I'll
 change it to an assertion.
 
 I don't think we should require users allocate all memory with g_malloc0.
 So no assertion either.

Assertion that is is NULL, followed by g_malloc0?

 If there's a leak there was always a leak

No, there wasn't because msix_uninit would have freed the memory.  That is,

msix_init
msix_uninit
msix_init
msix_uninit

had no leak.  Instead, now msix_free is going to be called just once,
right before freeing the object itself:

msix_init
msix_uninit
msix_init ***
msix_uninit
msix_free

and will have a leak at ***.  I don't think this can happen, unrealize
should never be followed by another realize right now, but perhaps in
the future it will be if we implement something like device_poweroff
and device_poweron.

Paolo

, let's focus on the
 API change in this series, OK?
 
 @@ -359,16 +363,26 @@ void msix_uninit(PCIDevice *dev, MemoryRegion 
 *table_bar, MemoryRegion *pba_bar)
  msix_free_irq_entries(dev);
  dev-msix_entries_nr = 0;
  memory_region_del_subregion(pba_bar, dev-msix_pba_mmio);
 -memory_region_destroy(dev-msix_pba_mmio);
 -g_free(dev-msix_pba);
 -dev-msix_pba = NULL;
  memory_region_del_subregion(table_bar, dev-msix_table_mmio);
 -memory_region_destroy(dev-msix_table_mmio);
 -g_free(dev-msix_table);
 +dev-cap_present = ~QEMU_PCI_CAP_MSIX;
 +}
 +
 +void msix_free(PCIDevice *dev)
 +{
 +if (dev-msix_pba) {
 +memory_region_destroy(dev-msix_pba_mmio);
 +g_free(dev-msix_pba);
 +}
 +dev-msix_pba = NULL;
 +
 +if (dev-msix_table) {
 +memory_region_destroy(dev-msix_table_mmio);
 +g_free(dev-msix_table);
 +}
  dev-msix_table = NULL;
 +
  g_free(dev-msix_entry_used);
  dev-msix_entry_used = NULL;
 -dev-cap_present = ~QEMU_PCI_CAP_MSIX;
  }
  
  void msix_uninit_exclusive_bar(PCIDevice *dev)
 As long as we had init and uninit, it was mostly
 self-documenting.
 Now, there are two cleanup functions, so please add documentation.

 Yes, will do.

 Paolo
 
 




Re: [Qemu-devel] [PATCH] blockdev: reset werror/rerror on drive_del

2013-06-05 Thread Stefan Hajnoczi
On Tue, Jun 04, 2013 at 06:37:27PM +0200, Markus Armbruster wrote:
 Stefan Hajnoczi stefa...@redhat.com writes:
 
  Paolo Bonzini pbonz...@redhat.com suggested the following test case:
 
  1. Launch a guest and wait at the GRUB boot menu:
 
qemu-system-x86_64 -enable-kvm -m 1024 \
 -drive if=none,cache=none,file=test.img,id=foo,werror=stop,rerror=stop
 -device virtio-blk-pci,drive=foo,id=virtio0,addr=4
 
  2. Hot unplug the device:
 
(qemu) drive_del foo
 
  3. Select the first boot menu entry
 
  Without this patch the guest pauses due to ENOMEDIUM.  But it is not
  possible to resolve this situation - the drive has become anonymous.
 
  With this patch the guest the guest gets the ENOMEDIUM error.
 
  Note that this scenario actually happens sometimes during libvirt disk
  hot unplug, where device_del is followed by drive_del.  I/O may still be
  submitted to the drive after drive_del if the guest does not process the
  PCI hot unplug notification.
 
  Reported-by: Dafna Ron d...@redhat.com
  Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
  ---
   blockdev.c | 4 
   1 file changed, 4 insertions(+)
 
  diff --git a/blockdev.c b/blockdev.c
  index d1ec99a..6eb81a3 100644
  --- a/blockdev.c
  +++ b/blockdev.c
  @@ -1180,6 +1180,10 @@ int do_drive_del(Monitor *mon, const QDict *qdict, 
  QObject **ret_data)
*/
   if (bdrv_get_attached_dev(bs)) {
   bdrv_make_anon(bs);
  +
  +/* Further I/O must not pause the guest */
  +bdrv_set_on_error(bs, BLOCKDEV_ON_ERROR_REPORT,
  +  BLOCKDEV_ON_ERROR_REPORT);
   } else {
   drive_uninit(drive_get_by_blockdev(bs));
   }
 
 The user gets exactly what he ordered.  He ordered stop on error, then
 provoked errors by turning the virtual block device into a virtual pile
 of scrap metal.  Because that's exactly what drive_del does when used
 while a device model is attached to the drive.
 
 The only sane use case for drive_del I can think of is revoking access
 to an image violently, after the guest failed to honor a hot unplug.
 
 Even then, using drive_del when the block device is removable is
 unnecessary.  Just rip out the medium with eject -f.  Look ma, no scrap
 metal.
 
 I'm not sure what you mean by it is not possible to resolve this
 situation.  The device is shot!  Can't see how that could be resolved.

This is the critical part: the guest is paused and there is no way to
resolve the continuous pause loop.  The drive is gone but the guest
hasn't PCI hot unplugged the storage controller.  As a user, there's
nothing you can do on the QEMU monitor to resume the guest - it will
just pause itself again.

This behavior is really bad, QEMU has basically wedged the guest into an
unrecoverable state and that's what I was trying to describe.

 I figure the bit that can't be resolved now is letting the user switch
 off stop on error safely before a drive_del.  Even if we had a command
 for that, there'd still be a window between that command's execution and
 drive_del's.  Your patch solves the problem by having drive_del switch
 it off unconditionally.  Oookay, but please document it, because it's
 not exactly obvious.

Thanks for the documentation suggestion, will add it in v2.

 Re the guest gets the ENOMEDIUM error: depends on the device.  I doubt
 disks can signal no medium, and even if they could, I doubt device
 drivers are prepared for it.

Yep, error reporting depends on the emulated storage controller.
virtio-blk and IDE just report a generic error status.

 Re this scenario actually happens sometimes during libvirt disk hot
 unplug, where device_del is followed by drive_del: if I remember
 correctly, libvirt disk hot unplug runs drive_del right after
 device_del, opening a window where the guest sees a dead device.  That's
 asking for trouble, and trouble is known to oblige.

Agreed.



Re: [Qemu-devel] [PATCH] blockdev: reset werror/rerror on drive_del

2013-06-05 Thread Fam Zheng
On Mon, 06/03 16:58, Stefan Hajnoczi wrote:
 Paolo Bonzini pbonz...@redhat.com suggested the following test case:
 
 1. Launch a guest and wait at the GRUB boot menu:
 
   qemu-system-x86_64 -enable-kvm -m 1024 \
-drive if=none,cache=none,file=test.img,id=foo,werror=stop,rerror=stop
-device virtio-blk-pci,drive=foo,id=virtio0,addr=4
 
 2. Hot unplug the device:
 
   (qemu) drive_del foo
 
 3. Select the first boot menu entry
 
 Without this patch the guest pauses due to ENOMEDIUM.  But it is not
 possible to resolve this situation - the drive has become anonymous.
 
 With this patch the guest the guest gets the ENOMEDIUM error.
s/the guest the guest/the guest/

-- 
Fam



Re: [Qemu-devel] [Qemu-stable] [PATCH stable-1.1] qga: set umask 0077 when daemonizing (CVE-2013-2007)

2013-06-05 Thread Michael Tokarev
04.06.2013 18:23, Anthony Liguori wrote:
 Andreas Färber afaer...@suse.de writes:
[]
 Do we have an active maintainer for 1.1 or 1.3? Unfortunately qemu.git
 MAINTAINERS has not been updated with stable branches and maintainers
 for some time. If not, I'd be willing to step up for security fixes at
 least.

I tried maintaining 1.1 (and I continue maintaining it in debian, but there
i'm not really interested in unrelated things), but after multiple promises
to get the tree published @qemu.org I gave up.

/mjt

 Can you setup a tree and do a pull request, also with a patch to set
 yourself up as maintainer?
 
 Thanks!
 
 Regards,
 
 Anthony Liguori
 
 
 

 Regards,
 Andreas

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




[Qemu-devel] [PATCH v2] blockdev: reset werror/rerror on drive_del

2013-06-05 Thread Stefan Hajnoczi
Paolo Bonzini pbonz...@redhat.com suggested the following test case:

1. Launch a guest and wait at the GRUB boot menu:

  qemu-system-x86_64 -enable-kvm -m 1024 \
   -drive if=none,cache=none,file=test.img,id=foo,werror=stop,rerror=stop
   -device virtio-blk-pci,drive=foo,id=virtio0,addr=4

2. Hot unplug the device:

  (qemu) drive_del foo

3. Select the first boot menu entry

Without this patch the guest pauses due to ENOMEDIUM.  The guest is
stuck in a continuous pause loop since the I/O request is retried and
fails immediately again when the guest is resumed.

With this patch the error is reported to the guest.

Note that this scenario actually happens sometimes during libvirt disk
hot unplug, where device_del is followed by drive_del.  I/O may still be
submitted to the drive after drive_del if the guest does not process the
PCI hot unplug notification.

Reported-by: Dafna Ron d...@redhat.com
Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
---
 blockdev.c  | 4 
 hmp-commands.hx | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/blockdev.c b/blockdev.c
index d1ec99a..6eb81a3 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1180,6 +1180,10 @@ int do_drive_del(Monitor *mon, const QDict *qdict, 
QObject **ret_data)
  */
 if (bdrv_get_attached_dev(bs)) {
 bdrv_make_anon(bs);
+
+/* Further I/O must not pause the guest */
+bdrv_set_on_error(bs, BLOCKDEV_ON_ERROR_REPORT,
+  BLOCKDEV_ON_ERROR_REPORT);
 } else {
 drive_uninit(drive_get_by_blockdev(bs));
 }
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 9cea415..4f5a3fd 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -185,6 +185,8 @@ Remove host block device.  The result is that guest 
generated IO is no longer
 submitted against the host device underlying the disk.  Once a drive has
 been deleted, the QEMU Block layer returns -EIO which results in IO
 errors in the guest for applications that are reading/writing to the device.
+These errors are always reported to the guest, regardless of the drive's error
+actions (drive options rerror, werror).
 ETEXI
 
 {
-- 
1.8.1.4




Re: [Qemu-devel] [PATCH] vmxnet3: fix NICState cleanup

2013-06-05 Thread Stefan Hajnoczi
On Tue, Jun 04, 2013 at 02:47:26PM +0200, Stefan Hajnoczi wrote:
 Use qemu_del_nic() instead of qemu_del_net_client() to correctly free
 the entire NICState.
 
 Reported-by: Paolo Bonzini pbonz...@redhat.com
 Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
 ---
  hw/net/vmxnet3.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks, applied to my net tree:
https://github.com/stefanha/qemu/commits/net

Stefan



Re: [Qemu-devel] [PATCH] virtio-net: fix wrong size of vlan filter table

2013-06-05 Thread Amos Kong
On Wed, Jun 05, 2013 at 03:21:30PM +0800, Amos Kong wrote:
 On Wed, Jun 05, 2013 at 02:13:48PM +0800, Amos Kong wrote:
  The MAX_VLAN is 4096, currently the vlan filter table has 512
  (4096  3) entries, it's wrong.
  
  One entry in vlan filter table can indicate 32(1  5) vlans,
  so the table should have 128 (4096  5) entries.

The patch is wrong, one entry takes 4 bytes. Sorry for the noise.

-- 
Amos.



Re: [Qemu-devel] [PATCH v2] blockdev: reset werror/rerror on drive_del

2013-06-05 Thread Kevin Wolf
Am 05.06.2013 um 10:33 hat Stefan Hajnoczi geschrieben:
 Paolo Bonzini pbonz...@redhat.com suggested the following test case:
 
 1. Launch a guest and wait at the GRUB boot menu:
 
   qemu-system-x86_64 -enable-kvm -m 1024 \
-drive if=none,cache=none,file=test.img,id=foo,werror=stop,rerror=stop
-device virtio-blk-pci,drive=foo,id=virtio0,addr=4
 
 2. Hot unplug the device:
 
   (qemu) drive_del foo
 
 3. Select the first boot menu entry

Can we have a qtest or qemu-iotests version of this manual test case?

 Without this patch the guest pauses due to ENOMEDIUM.  The guest is
 stuck in a continuous pause loop since the I/O request is retried and
 fails immediately again when the guest is resumed.
 
 With this patch the error is reported to the guest.
 
 Note that this scenario actually happens sometimes during libvirt disk
 hot unplug, where device_del is followed by drive_del.  I/O may still be
 submitted to the drive after drive_del if the guest does not process the
 PCI hot unplug notification.
 
 Reported-by: Dafna Ron d...@redhat.com
 Signed-off-by: Stefan Hajnoczi stefa...@redhat.com

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



Re: [Qemu-devel] Could configure generate QEMU's linker scripts?

2013-06-05 Thread Claudio Fontana
On 04.06.2013 18:13, Peter Maydell wrote:
 On 4 June 2013 16:55, Claudio Fontana claudio.font...@huawei.com wrote:
 I'm trying to get this to run, in order to be able to test the
 aarch64 TCG User mode support I have under development.
 
 Does it work as a first pass with aarch64 put in the
 configure list of doesn't need a linker script?

Yes! :)

 Since we now default to reserve 4GB space and
 set guest-base this should work OK (if all the
 TCG bits are right). Fiddling with the start
 address is only needed for the -R 0 no-reserved-mem
 case.
 
 I think this should let you debug the two issues
 separately...
 
 thanks
 -- PMM
 

$ ./qemu-x86_64 ./user_mode_test_binary_x86.out
I am a binary executable, and I actually run!
$

I'll make it nice now, then post a series for TCG User mode.
I am using my quirky workaround for the getdents issue, I will now apply 
Peter's patch instead and test the whole thing.

Claudio





Re: [Qemu-devel] [PATCH 1/2] nvram: Add TPM NVRAM implementation

2013-06-05 Thread Stefan Hajnoczi
On Tue, Jun 04, 2013 at 02:18:40PM -0400, Corey Bryant wrote:
 Provides TPM NVRAM implementation that enables storing of TPM
 NVRAM data in a persistent image file.  The block driver is
 used to read/write the drive image.  This will enable, for
 example, an ecrypted QCOW2 image to be used to store sensitive
 keys.
 
 This patch provides APIs that a TPM backend can use to read and
 write data.
 
 Signed-off-by: Corey Bryant cor...@linux.vnet.ibm.com
 ---
  hw/tpm/Makefile.objs |1 +
  hw/tpm/tpm_nvram.c   |  399 
 ++
  hw/tpm/tpm_nvram.h   |   25 +++
  3 files changed, 425 insertions(+), 0 deletions(-)
  create mode 100644 hw/tpm/tpm_nvram.c
  create mode 100644 hw/tpm/tpm_nvram.h
 
 diff --git a/hw/tpm/Makefile.objs b/hw/tpm/Makefile.objs
 index 99f5983..49faef4 100644
 --- a/hw/tpm/Makefile.objs
 +++ b/hw/tpm/Makefile.objs
 @@ -1,2 +1,3 @@
  common-obj-$(CONFIG_TPM_TIS) += tpm_tis.o
 +common-obj-$(CONFIG_TPM_TIS) += tpm_nvram.o
  common-obj-$(CONFIG_TPM_PASSTHROUGH) += tpm_passthrough.o
 diff --git a/hw/tpm/tpm_nvram.c b/hw/tpm/tpm_nvram.c
 new file mode 100644
 index 000..95ff396
 --- /dev/null
 +++ b/hw/tpm/tpm_nvram.c
 @@ -0,0 +1,399 @@
 +/*
 + * TPM NVRAM - enables storage of persistent NVRAM data on an image file
 + *
 + * Copyright (C) 2013 IBM Corporation
 + *
 + * Authors:
 + *  Stefan Bergerstef...@us.ibm.com
 + *  Corey Bryant cor...@linux.vnet.ibm.com
 + *
 + * This work is licensed under the terms of the GNU GPL, version 2 or later.
 + * See the COPYING file in the top-level directory.
 + */
 +
 +#include tpm_nvram.h
 +#include block/block_int.h
 +#include qemu/thread.h
 +#include sysemu/sysemu.h
 +
 +/* #define TPM_NVRAM_DEBUG */
 +
 +#ifdef TPM_NVRAM_DEBUG
 +#define DPRINTF(fmt, ...) \
 +do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
 +#else
 +#define DPRINTF(fmt, ...) \
 +do { } while (0)
 +#endif

I suggest:

#define TPM_NVRAM_DEBUG 0
#define DPRINTF(fmt, ...) \
do { \
if (TPM_NVRAM_DEBUG) { \
fprintf(stderr, fmt, ## __VA_ARGS__); \
} \
} while (0)

This approach prevents bitrot since the compiler always parses the
printf() whether TPM_NVRAM_DEBUG is 0 or 1.  If you #ifdef out the code
completely, like above, then you don't notice compiler warnings/errors
until you actually #define TPM_NVRAM_DEBUG (i.e. prone to bitrot).

 +
 +/* Round a value up to the next SIZE */
 +#define ROUNDUP(VAL, SIZE) \
 +(((VAL)+(SIZE)-1)  ~((SIZE)-1))

Please drop this macro and use include/qemu/osdep.h:ROUND_UP()

 +
 +/* Get the number of sectors required to contain SIZE bytes */
 +#define NUM_SECTORS(SIZE) \
 +(ROUNDUP(SIZE, BDRV_SECTOR_SIZE) / BDRV_SECTOR_SIZE)

Please drop this macro and use include/qemu/osdep.h:DIV_ROUND_UP() instead.

 +
 +/* Read/write request data */
 +typedef struct TPMNvramRWRequest {
 +BlockDriverState *bdrv;
 +bool is_write;
 +uint64_t sector_num;
 +int num_sectors;
 +uint8_t **blob_r;
 +uint8_t *blob_w;
 +uint32_t size;
 +QEMUIOVector *qiov;
 +bool done;
 +int rc;
 +
 +QemuMutex completion_mutex;
 +QemuCond completion;
 +
 +QSIMPLEQ_ENTRY(TPMNvramRWRequest) list;
 +} TPMNvramRWRequest;
 +
 +/* Mutex protected queue of read/write requests */
 +static QemuMutex tpm_nvram_rwrequests_mutex;
 +static QSIMPLEQ_HEAD(, TPMNvramRWRequest) tpm_nvram_rwrequests =
 +QSIMPLEQ_HEAD_INITIALIZER(tpm_nvram_rwrequests);
 +
 +static QEMUBH *tpm_nvram_bh;
 +
 +/*
 + * Increase the drive size if it's too small to store the blob
 + */
 +static int tpm_nvram_adjust_size(BlockDriverState *bdrv, uint64_t sector_num,
 + int num_sectors)
 +{
 +int rc = 0;
 +int64_t drive_size, required_size;
 +
 +drive_size = bdrv_getlength(bdrv);
 +if (drive_size  0) {
 +DPRINTF(%s: Unable to determine TPM NVRAM drive size\n, __func__);
 +rc = drive_size;
 +goto err_exit;
 +}
 +
 +required_size = (sector_num + num_sectors) * BDRV_SECTOR_SIZE;
 +
 +if (drive_size  required_size) {
 +rc = bdrv_truncate(bdrv, required_size);
 +if (rc  0) {
 +DPRINTF(%s: TPM NVRAM drive too small\n, __func__);
 +}
 +}
 +
 +err_exit:
 +return rc;
 +}
 +
 +/*
 + * Coroutine that reads a blob from the drive asynchronously
 + */
 +static void coroutine_fn tpm_nvram_co_read(void *opaque)
 +{
 +TPMNvramRWRequest *rwr = opaque;
 +
 +rwr-rc = bdrv_co_readv(rwr-bdrv,
 +rwr-sector_num,
 +rwr-num_sectors,
 +rwr-qiov);
 +rwr-done = true;
 +}
 +
 +/*
 + * Coroutine that writes a blob to the drive asynchronously
 + */
 +static void coroutine_fn tpm_nvram_co_write(void *opaque)
 +{
 +TPMNvramRWRequest *rwr = opaque;
 +
 +rwr-rc = bdrv_co_writev(rwr-bdrv,
 + rwr-sector_num,
 + rwr-num_sectors,
 +

Re: [Qemu-devel] [PATCH] target-ppc kvm: save cr register

2013-06-05 Thread David Gibson
On Wed, Jun 05, 2013 at 12:36:04PM +1000, Alexey Kardashevskiy wrote:
 On 06/04/2013 10:11 PM, David Gibson wrote:
  On Thu, May 30, 2013 at 07:26:10PM +1000, Alexey Kardashevskiy wrote:
  This adds a missing code to save CR (condition register) via
  kvm_arch_put_registers(). kvm_arch_get_registers() already has it.
 
  Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru
  
  Huh.  I can't believe that's been broken for so long.  I'll put that
  in my tree.
 
 We probably have another bug which compensates this one but just have not
 found it yet :-D

Yay :/.

  I meant to post my pending patches at the end of last week, but was
  sidetracked by a minor injury :(.
 
 Sigh...
 What exactly are you going to post? PCI rework?

Well until now the only thing I had in my ppc-next tree was the change
of default machine.  I have the PCI stuff too, but that's no PCI
related so I was going to post those separately, rather than as a PPC
pull request.

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


pgpBtZnVifmI7.pgp
Description: PGP signature


Re: [Qemu-devel] [PATCH 00/39] Delay destruction of memory regions to instance_finalize

2013-06-05 Thread Andreas Färber
Am 04.06.2013 20:51, schrieb Paolo Bonzini:
 This series changes all PCI devices (the sole to support hotplug
 _and_ use MemoryRegions) to do memory_region_del_subregion at
 unrealize time, and memory_region_destroy at instance_finalize
 time.

The general idea looks good.

Could you please follow-up with a patch that switches from exit to
unrealize?

Also I notice some patches are accessing parent fields directly - please
use BUS(), PCI_DEVICE() etc. to hide this.

Andreas

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



Re: [Qemu-devel] [PATCH 12/13] target-ppc: Add helper for KVM_PPC_RTAS_DEFINE_TOKEN

2013-06-05 Thread David Gibson
On Tue, Jun 04, 2013 at 10:21:04PM +1000, Alexey Kardashevskiy wrote:
 From: David Gibson da...@gibson.dropbear.id.au
 
 Recent PowerKVM allows the kernel to intercept some RTAS calls from the
 guest directly.  This is used to implement the more efficient in-kernel
 XICS for example.  qemu is still responsible for assigning the RTAS token
 numbers however, and needs to tell the kernel which RTAS function name is
 assigned to a given token value.  This patch adds a convenience wrapper for
 the KVM_PPC_RTAS_DEFINE_TOKEN ioctl() which is used for this purpose.

Um.. have you actually compiled this on ppc.  AFAICT, the necessary
ioctl constant isn't yet imported into the mainline qemu tree.

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


pgpnq1mNTD6sB.pgp
Description: PGP signature


Re: [Qemu-devel] [PATCH 1/2] Add Linux libnuma detection

2013-06-05 Thread Andreas Färber
Am 05.06.2013 05:58, schrieb Wanlong Gao:
 Add detection of libnuma (mostly contained in the numactl package)
 to the configure script. Currently this is Linux only, but can be
 extended later should the need for other interfaces come up.
 Can be enabled or disabled on the command line, default is use if
 available.
 
 Original-signed-off-by: Andre Przywara andre.przyw...@amd.com

This should be just Signed-off-by, the difference between From and Sob
already indicates you changed his code.

 Signed-off-by: Wanlong Gao gaowanl...@cn.fujitsu.com
 ---
  configure | 32 
  1 file changed, 32 insertions(+)
 
 diff --git a/configure b/configure
 index 1654413..d897f98 100755
 --- a/configure
 +++ b/configure
 @@ -242,6 +242,7 @@ gtk=
  gtkabi=2.0
  tpm=no
  libssh2=
 +numa=yes

This should be  by default - it is not needed by linux-user and when
--enable-numa is used we should error out if it's not there.

  
  # parse CC options first
  for opt do
 @@ -937,6 +938,10 @@ for opt do
;;
--enable-libssh2) libssh2=yes
;;
 +  --disable-numa) numa=no
 +  ;;
 +  --enable-numa) numa=yes
 +  ;;
*) echo ERROR: unknown option $opt; show_help=yes
;;
esac
 @@ -1151,6 +1156,8 @@ echo   --gcov=GCOV  use specified gcov 
 [$gcov_tool]
  echo   --enable-tpm enable TPM support
  echo   --disable-libssh2disable ssh block device support
  echo   --enable-libssh2 enable ssh block device support
 +echo   --disable-numa   disable host Linux NUMA support
 +echo   --enable-numaenable host Linux NUMA support
  echo 
  echo NOTE: The object files are built at the place where configure is 
 launched
  exit 1
 @@ -2382,6 +2389,27 @@ EOF
  fi
  
  ##
 +# libnuma probe
 +
 +if test $numa = yes ; then

Requires to check for != no here.

 +  numa=no
 +  cat  $TMPC  EOF
 +#include numa.h
 +int main(void) { return numa_available(); }
 +EOF
 +
 +  if compile_prog  -lnuma ; then
 +numa=yes
 +libs_softmmu=-lnuma $libs_softmmu
 +  else
 +if test $numa = yes ; then
 +  feature_not_found linux NUMA (install numactl?)
 +fi
 +numa=no
 +  fi
 +fi
 +
 +##
  # linux-aio probe
  
  if test $linux_aio != no ; then
 @@ -3550,6 +3578,7 @@ echo TPM support   $tpm
  echo libssh2 support   $libssh2
  echo TPM passthrough   $tpm_passthrough
  echo QOM debugging $qom_cast_debug
 +echo NUMA host support $numa
  
  if test $sdl_too_old = yes; then
  echo - Your SDL version is too old - please upgrade to have SDL support
 @@ -3584,6 +3613,9 @@ echo extra_cflags=$EXTRA_CFLAGS  $config_host_mak
  echo extra_ldflags=$EXTRA_LDFLAGS  $config_host_mak
  echo qemu_localedir=$qemu_localedir  $config_host_mak
  echo libs_softmmu=$libs_softmmu  $config_host_mak
 +if test $numa = yes; then
 +  echo CONFIG_NUMA=y  $config_host_mak
 +fi
  
  echo ARCH=$ARCH  $config_host_mak
  
 

Regards,
Andreas

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



Re: [Qemu-devel] [PATCH 11/13] pseries: savevm support for PCI host bridge

2013-06-05 Thread David Gibson
On Tue, Jun 04, 2013 at 10:21:03PM +1000, Alexey Kardashevskiy wrote:
 Author: David Gibson da...@gibson.dropbear.id.au
 
 This adds the necessary support for saving the state of the PAPR virtual
 PCI host bridge (or host bridges).

I think the PCI cleanup patches I was working on need to go in before
this, to make sure the migration stream pieces for PCI have same paths
from the beginning.

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


pgpoJvfxi4gGc.pgp
Description: PGP signature


Re: [Qemu-devel] [PATCH 04/13] pseries: savevm support for XICS interrupt controller

2013-06-05 Thread David Gibson
On Wed, Jun 05, 2013 at 01:22:02PM +1000, Alexey Kardashevskiy wrote:
 On 06/04/2013 10:20 PM, Alexey Kardashevskiy wrote:
[snip]
  +static int ics_post_load(void *opaque, int version_id)
  +{
  +int i;
  +struct ics_state *ics = opaque;
  +
  +for (i = 0; i  ics-nr_irqs; i++) {
 
 Obviously here is a bug...
 
 -for (i = 0; i  ics-nr_irqs; i++) {
 +for (i = 0; i  ics-icp-nr_servers; i++) {

Ah.. yes.  Although it would be a little nicer to avoid the duplicate
calls to ics_resend() that will cause.  Still the simple version
should be correct for now.  Please resend with this fixed.

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


pgpJE8wHg9u01.pgp
Description: PGP signature


Re: [Qemu-devel] [Qemu] [PATCH for 1.5] ui/gtk.c: Fix *BSD build of Gtk+ UI

2013-06-05 Thread Michael Tokarev
23.05.2013 02:38, Brad Smith wrote:
 Fix the build of the Gtk+ UI on *BSD systems.

Can you please describe what exactly was broken on *BSD
systems, -- which file(s) needs this additional
termios.h include?

I want to fix this properly, because now it isn't
nitpicking, as you say, anymore -- after the
previous pbonzini's changes it does not build
on debian sparc anymore due to some conflicting
includes (which is an unrelated issue, but is
triggered now because every .c file includes
a ton of #defines).

I already asked you the same question on 25.05,
which is about two weeks ago by now, -- did you
had no time to reply so far?

Thanks,

/mjt

 Signed-off-by: Brad Smith b...@comstyle.com
 Reviewed-by: Laszlo Ersek ler...@redhat.com
 Message-id: 20130521161324.ga29...@rox.home.comstyle.com
 Signed-off-by: Anthony Liguori aligu...@us.ibm.com
 
 diff --git a/include/qemu-common.h b/include/qemu-common.h
 index af769f5..c944bb7 100644
 --- a/include/qemu-common.h
 +++ b/include/qemu-common.h
 @@ -45,6 +45,7 @@
  #if defined(__GLIBC__)
  # include pty.h
  #elif defined CONFIG_BSD
 +# include termios.h
  # if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || 
 defined(__DragonFly__)
  #  include libutil.h
  # else
 




[Qemu-devel] qemu openpty

2013-06-05 Thread Michael Tokarev
Hello.

One of old issues with compatibility between different
*Nix systems was the way how pty pairs were allocated.

And qemu have a twist in #includes, depending on which
platform it is run, and quite some compat cruft in
qemu-char.c about this issue.

Here it is, from qemu-char.c:

#ifdef __sun__
/* Once Solaris has openpty(), this is going to be removed. */
static int openpty(int *amaster, int *aslave, char *name,
   struct termios *termp, struct winsize *winp)
{...}

static void cfmakeraw (struct termios *termios_p)
{...}
#endif

and later on, openpty() is used in the code.  Note that
both functions are marked as static - static to the
source file, qemu-char.c.

Now, we have ui/gtk.c, which calls openpty() and cfmakeraw()
too, but this time, there's no compat alternative implementation
provided.

Does this mean we don't need the old compat implementation
anymore?  Does gtk ui work (or at least builds) on solaris?

If gtk builds fine on solaris, it should be safe to remove
these static functions from qemu-char.c.

If not, we should obviously re-use these for ui/gtk.c --
for which I'd create a new file, say, qemu-openpty.c,
with all the system-dependent stuff inside, and create
a wrapper function, qemu_openpty(), to do the work,
and, ofcourse, remove pty.h and other fancy stuff
(like stropts.h for solaris) from qemu-common.h (!!!)
where it finally ended up.

Thanks,

/mjt



Re: [Qemu-devel] [PATCH 11/39] msix: split msix_free from msix_uninit

2013-06-05 Thread Michael S. Tsirkin
On Wed, Jun 05, 2013 at 09:48:19AM +0200, Paolo Bonzini wrote:
 Il 05/06/2013 06:53, Michael S. Tsirkin ha scritto:
  On Wed, Jun 05, 2013 at 12:40:00AM +0200, Paolo Bonzini wrote:
  Il 05/06/2013 00:03, Michael S. Tsirkin ha scritto:
  +if (dev-msix_table || dev-msix_pba || dev-msix_entry_used) {
  +msix_free(dev);
  +}
  +
   dev-msix_table = g_malloc0(table_size);
   dev-msix_pba = g_malloc0(pba_size);
   dev-msix_entry_used = g_malloc0(nentries * sizeof 
  *dev-msix_entry_used);
  Wow msix_init calls msix_free, and not on error path?
  What's going on here?
 
  I wasn't too sure that you could get here only with NULL
  msix_table/pba/entry_used and wanted to protect against leaks.  I'll
  change it to an assertion.
  
  I don't think we should require users allocate all memory with g_malloc0.
  So no assertion either.
 
 Assertion that is is NULL, followed by g_malloc0?

No because who sets it to NULL the first time?
msix_init just started.

  If there's a leak there was always a leak
 
 No, there wasn't because msix_uninit would have freed the memory.  That is,
 
 msix_init
 msix_uninit
 msix_init
 msix_uninit
 
 had no leak.  Instead, now msix_free is going to be called just once,
 right before freeing the object itself:
 
 msix_init
 msix_uninit
 msix_init ***
 msix_uninit
 msix_free
 
 and will have a leak at ***.

Yes. And this looks completely sane from outside,
so this is a bad API.
The way to fix it is not with asserts in code, we need a good API:
alloc/free init/uninit ...

The problem apparently starts in generic code, let's fix it there?

  I don't think this can happen, unrealize
 should never be followed by another realize right now,

This is not an msix specific problem, I don't think msix should
debug generic core - this will just lead to proliferation of asserts.

This really should be documented prominently in generic code.

Also how about some asserts in generic code making sure ordering
is sane?


 but perhaps in
 the future it will be if we implement something like device_poweroff
 and device_poweron.
 
 Paolo

 , let's focus on the
  API change in this series, OK?
  
  @@ -359,16 +363,26 @@ void msix_uninit(PCIDevice *dev, MemoryRegion 
  *table_bar, MemoryRegion *pba_bar)
   msix_free_irq_entries(dev);
   dev-msix_entries_nr = 0;
   memory_region_del_subregion(pba_bar, dev-msix_pba_mmio);
  -memory_region_destroy(dev-msix_pba_mmio);
  -g_free(dev-msix_pba);
  -dev-msix_pba = NULL;
   memory_region_del_subregion(table_bar, dev-msix_table_mmio);
  -memory_region_destroy(dev-msix_table_mmio);
  -g_free(dev-msix_table);
  +dev-cap_present = ~QEMU_PCI_CAP_MSIX;
  +}
  +
  +void msix_free(PCIDevice *dev)
  +{
  +if (dev-msix_pba) {
  +memory_region_destroy(dev-msix_pba_mmio);
  +g_free(dev-msix_pba);
  +}
  +dev-msix_pba = NULL;
  +
  +if (dev-msix_table) {
  +memory_region_destroy(dev-msix_table_mmio);
  +g_free(dev-msix_table);
  +}
   dev-msix_table = NULL;
  +
   g_free(dev-msix_entry_used);
   dev-msix_entry_used = NULL;
  -dev-cap_present = ~QEMU_PCI_CAP_MSIX;
   }
   
   void msix_uninit_exclusive_bar(PCIDevice *dev)
  As long as we had init and uninit, it was mostly
  self-documenting.
  Now, there are two cleanup functions, so please add documentation.
 
  Yes, will do.
 
  Paolo
  
  



[Qemu-devel] [PATCH v5] net: add support of mac-programming over macvtap in QEMU side

2013-06-05 Thread Amos Kong
Currently macvtap based macvlan device is working in promiscuous
mode, we want to implement mac-programming over macvtap through
Libvirt for better performance.

Design:
QEMU notifies Libvirt when rx-filter config is changed in guest,
then Libvirt query the rx-filter information by a monitor command,
and sync the change to macvtap device. Related rx-filter config
of the nic contains main mac, rx-mode items and vlan table.

This patch adds a QMP event to notify management of rx-filter change,
and adds a monitor command for management to query rx-filter
information.

For reducing length of output, we just return the entries of vlan
filter table that have active vlan.

Event_throttle API can avoid the events to flood QMP client, but it
could cause an unexpected delay. So a flag for each nic is used to
avoid events flooding, if management doesn't query rx-filter after
it receives one event, new events won't be emitted to QMP monitor.

There maybe exist an uncontrollable delay if we let Libvirt do the
real change, guests normally expect rx-filter updates immediately.
But it's another separate issue, we can investigate it when the
work in Libvirt side is done.

Signed-off-by: Amos Kong ak...@redhat.com
---
v2: add argument to filter mac-table info of single nic (Stefan)
update the document, add event notification
v3: rename to rx-filter, add main mac, avoid events flooding (MST)
fix error process (Stefan), fix qmp interface (Eric)
v4: process qerror in hmp, cleanup (Luiz)
set flag for each device, add device path in event, add
helper for g_strdup_printf (MST)
fix qmp document (Eric)
v5: add path in doc, define notify flag to unsigned (Eric)
add vlan table (Jason), drop monitor cmd
---
 QMP/qmp-events.txt|  20 +
 hw/net/virtio-net.c   | 112 ++
 include/monitor/monitor.h |   1 +
 include/net/net.h |   3 ++
 monitor.c |   1 +
 net/net.c |  47 +++
 qapi-schema.json  |  89 
 qmp-commands.hx   |  66 +++
 8 files changed, 339 insertions(+)

diff --git a/QMP/qmp-events.txt b/QMP/qmp-events.txt
index 92fe5fb..885230e 100644
--- a/QMP/qmp-events.txt
+++ b/QMP/qmp-events.txt
@@ -172,6 +172,26 @@ Data:
   },
   timestamp: { seconds: 1265044230, microseconds: 450486 } }
 
+NIC_RX_FILTER_CHANGED
+-
+
+Emitted when rx-filter configuration of nic is changed by the guest.
+Each nic has a flag to control event emit, the flag is set to false
+when it emits one event of the nic, the flag is set to true when
+management queries the rx-filter of the nic. This is used to avoid
+events flooding.
+
+Data:
+
+- name: net client name (json-string)
+- path: device path (json-string)
+
+{ event: NIC_RX_FILTER_CHANGED,
+  data: { name: vnet0,
+path: /machine/peripheral/vnet0/virtio-backend },
+  timestamp: { seconds: 1368697518, microseconds: 326866 } }
+}
+
 RESET
 -
 
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 1ea9556..ae1eab6 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -21,6 +21,8 @@
 #include hw/virtio/virtio-net.h
 #include net/vhost_net.h
 #include hw/virtio/virtio-bus.h
+#include qapi/qmp/qjson.h
+#include monitor/monitor.h
 
 #define VIRTIO_NET_VM_VERSION11
 
@@ -192,6 +194,104 @@ static void virtio_net_set_link_status(NetClientState *nc)
 virtio_net_set_status(vdev, vdev-status);
 }
 
+static void rxfilter_notify(NetClientState *nc)
+{
+QObject *event_data;
+VirtIONet *n = qemu_get_nic_opaque(nc);
+
+if (nc-rxfilter_notify_enabled) {
+event_data = qobject_from_jsonf({ 'name': %s, 'path': %s },
+   n-netclient_name,
+   object_get_canonical_path(OBJECT(n-qdev)));
+monitor_protocol_event(QEVENT_NIC_RX_FILTER_CHANGED, event_data);
+qobject_decref(event_data);
+/* disable event notification to avoid events flooding */
+nc-rxfilter_notify_enabled = 0;
+}
+}
+
+static char *mac_strdup_printf(uint8_t *mac)
+{
+return g_strdup_printf(%.2x:%.2x:%.2x:%.2x:%.2x:%.2x, mac[0],
+mac[1], mac[2], mac[3], mac[4], mac[5]);
+}
+
+static RxFilterInfo *virtio_net_query_rxfilter(NetClientState *nc)
+{
+VirtIONet *n = qemu_get_nic_opaque(nc);
+RxFilterInfo *info;
+strList *str_list = NULL;
+strList *entry;
+VlanTableEntryList *vlan_list = NULL;
+VlanTableEntryList *vlan_entry;
+VlanTableEntry *table_entry;
+int i;
+
+info = g_malloc0(sizeof(*info));
+info-name = g_strdup(nc-name);
+info-promiscuous = n-promisc;
+
+if (n-nouni) {
+info-unicast = RX_STATE_NONE;
+} else if (n-alluni) {
+info-unicast = RX_STATE_ALL;
+} else {
+info-unicast = RX_STATE_NORMAL;
+}
+
+if (n-nomulti) {
+info-multicast = RX_STATE_NONE;
+} else if (n-allmulti) 

Re: [Qemu-devel] [PATCH v5] net: add support of mac-programming over macvtap in QEMU side

2013-06-05 Thread Daniel P. Berrange
On Wed, Jun 05, 2013 at 06:42:13PM +0800, Amos Kong wrote:
 Currently macvtap based macvlan device is working in promiscuous
 mode, we want to implement mac-programming over macvtap through
 Libvirt for better performance.
 
 Design:
 QEMU notifies Libvirt when rx-filter config is changed in guest,
 then Libvirt query the rx-filter information by a monitor command,
 and sync the change to macvtap device. Related rx-filter config
 of the nic contains main mac, rx-mode items and vlan table.
 
 This patch adds a QMP event to notify management of rx-filter change,
 and adds a monitor command for management to query rx-filter
 information.
 
 For reducing length of output, we just return the entries of vlan
 filter table that have active vlan.
 
 Event_throttle API can avoid the events to flood QMP client, but it
 could cause an unexpected delay. So a flag for each nic is used to
 avoid events flooding, if management doesn't query rx-filter after
 it receives one event, new events won't be emitted to QMP monitor.
 
 There maybe exist an uncontrollable delay if we let Libvirt do the
 real change, guests normally expect rx-filter updates immediately.
 But it's another separate issue, we can investigate it when the
 work in Libvirt side is done.

What work is libvirt expected to do in response to these events ?
It this just about updating the ebtables rules to allow packets
with the newly configured MAC addr to be sent/received on the
tap backend ?

Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|



Re: [Qemu-devel] [PATCH] target-ppc kvm: save cr register

2013-06-05 Thread Alexey Kardashevskiy
On 05.06.2013 19:22, David Gibson wrote:

 I meant to post my pending patches at the end of last week, but was
 sidetracked by a minor injury :(.

 Sigh...
 What exactly are you going to post? PCI rework?
 
 Well until now the only thing I had in my ppc-next tree was the change
 of default machine. 

btw what is going on with this patch?

 I have the PCI stuff too, but that's no PCI
 related so I was going to post those separately, rather than as a PPC
 pull request.


I guess I still want this stuff for VFIO, some bits.



-- 
With best regards

Alexey Kardashevskiy -- icq: 52150396



Re: [Qemu-devel] [PATCH V13 3/6] qmp: add recursive member in ImageInfo

2013-06-05 Thread Stefan Hajnoczi
On Mon, May 27, 2013 at 09:28:59AM +0800, Wenchao Xia wrote:
 于 2013-5-26 0:10, Eric Blake 写道:
 On 05/24/2013 10:24 PM, Wenchao Xia wrote:
   void bdrv_query_image_info(BlockDriverState *bs,
  ImageInfo **p_info,
  Error **errp)
 diff --git a/qapi-schema.json b/qapi-schema.json
 index ef1f657..a02999d 100644
 --- a/qapi-schema.json
 +++ b/qapi-schema.json
 @@ -236,6 +236,8 @@
   #
   # @snapshots: #optional list of VM snapshots
   #
 +# @backing-image: #optional info of the backing image (since 1.6)
 +#
   # Since: 1.3
   #
   ##
 @@ -245,7 +247,8 @@
  '*actual-size': 'int', 'virtual-size': 'int',
  '*cluster-size': 'int', '*encrypted': 'bool',
  '*backing-filename': 'str', '*full-backing-filename': 'str',
 -   '*backing-filename-format': 'str', '*snapshots': 
 ['SnapshotInfo'] } }
 +   '*backing-filename-format': 'str', '*snapshots': 
 ['SnapshotInfo'],
 +   '*backing-image': 'ImageInfo' } }
 
 The API change looks fine, except there is no code change to actually
 populate the new field.  This hunk should probably be squashed with the
 patch that implements the field.  Also, are you missing any changes to
 qmp-commands.hx?
 
   nop, in next patch qmp-commands.hx parts is added. Just to make
 review easier, after that I am fine to squash them.

The qapi change should be together with the code that implements it.  I
need to see the code in order to review the documentation change.

Stefan



Re: [Qemu-devel] [PATCH v2] linux-user: Allow getdents to be provided by getdents64

2013-06-05 Thread Claudio Fontana
On 04.06.2013 13:12, Peter Maydell wrote:
 Newer architectures may only implement the getdents64 syscall, not
 getdents. Provide an implementation of getdents in terms of getdents64
 so that we can run getdents-using targets on a getdents64-only host.
 
 Signed-off-by: Peter Maydell peter.mayd...@linaro.org
 Message-id: 1370193044-24535-1-git-send-email-peter.mayd...@linaro.org
 ---
 Changes v1-v2:
  * memmove() call moved to before we write inode/offset/reclen
  * wrapped a stray long line that snuck in somehow
 
  linux-user/syscall.c |   61 
 +-
  1 file changed, 60 insertions(+), 1 deletion(-)
 

I tested the change, and it works, however I get this during compilation:

linux-user/syscall.c:382:12: warning: 'sys_futimesat' defined but not used 
[-Wunused-function]

 diff --git a/linux-user/syscall.c b/linux-user/syscall.c
 index 0099d64..4151c78 100644
 --- a/linux-user/syscall.c
 +++ b/linux-user/syscall.c
 @@ -223,8 +223,11 @@ static int gettid(void) {
  return -ENOSYS;
  }
  #endif
 +#ifdef __NR_getdents
  _syscall3(int, sys_getdents, uint, fd, struct linux_dirent *, dirp, uint, 
 count);
 -#if defined(TARGET_NR_getdents64)  defined(__NR_getdents64)
 +#endif
 +#if !defined(__NR_getdents) || \
 +(defined(TARGET_NR_getdents64)  defined(__NR_getdents64))
  _syscall3(int, sys_getdents64, uint, fd, struct linux_dirent64 *, dirp, 
 uint, count);
  #endif
  #if defined(TARGET_NR__llseek)  defined(__NR_llseek)
 @@ -7123,6 +7126,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long 
 arg1,
  break;
  #endif
  case TARGET_NR_getdents:
 +#ifdef __NR_getdents
  #if TARGET_ABI_BITS == 32  HOST_LONG_BITS == 64
  {
  struct target_dirent *target_dirp;
 @@ -7195,6 +7199,61 @@ abi_long do_syscall(void *cpu_env, int num, abi_long 
 arg1,
  unlock_user(dirp, arg2, ret);
  }
  #endif
 +#else
 +/* Implement getdents in terms of getdents64 */
 +{
 +struct linux_dirent64 *dirp;
 +abi_long count = arg3;
 +
 +dirp = lock_user(VERIFY_WRITE, arg2, count, 0);
 +if (!dirp) {
 +goto efault;
 +}
 +ret = get_errno(sys_getdents64(arg1, dirp, count));
 +if (!is_error(ret)) {
 +/* Convert the dirent64 structs to target dirent.  We do this
 + * in-place, since we can guarantee that a target_dirent is 
 no
 + * larger than a dirent64; however this means we have to be
 + * careful to read everything before writing in the new 
 format.
 + */
 +struct linux_dirent64 *de;
 +struct target_dirent *tde;
 +int len = ret;
 +int tlen = 0;
 +
 +de = dirp;
 +tde = (struct target_dirent *)dirp;
 +while (len  0) {
 +int namelen, treclen;
 +int reclen = de-d_reclen;
 +uint64_t ino = de-d_ino;
 +int64_t off = de-d_off;
 +uint8_t type = de-d_type;
 +
 +namelen = strlen(de-d_name);
 +treclen = offsetof(struct target_dirent, d_name)
 ++ namelen + 2;
 +treclen = QEMU_ALIGN_UP(treclen, sizeof(abi_long));
 +
 +memmove(tde-d_name, de-d_name, namelen + 1);
 +tde-d_ino = tswapal(ino);
 +tde-d_off = tswapal(off);
 +tde-d_reclen = tswap16(treclen);
 +/* The target_dirent type is in what was formerly a 
 padding
 + * byte at the end of the structure:
 + */
 +*(((char *)tde) + treclen - 1) = type;
 +
 +de = (struct linux_dirent64 *)((char *)de + reclen);
 +tde = (struct target_dirent *)((char *)tde + treclen);
 +len -= reclen;
 +tlen += treclen;
 +}
 +ret = tlen;
 +}
 +unlock_user(dirp, arg2, ret);
 +}
 +#endif
  break;
  #if defined(TARGET_NR_getdents64)  defined(__NR_getdents64)
  case TARGET_NR_getdents64:
 


-- 
Claudio Fontana
Server OS Architect
Huawei Technologies Duesseldorf GmbH
Riesstraße 25 - 80992 München

office: +49 89 158834 4135
mobile: +49 15253060158




Re: [Qemu-devel] [PATCH 11/13] pseries: savevm support for PCI host bridge

2013-06-05 Thread Alexey Kardashevskiy
On 05.06.2013 20:00, David Gibson wrote:
 On Tue, Jun 04, 2013 at 10:21:03PM +1000, Alexey Kardashevskiy wrote:
 Author: David Gibson da...@gibson.dropbear.id.au

 This adds the necessary support for saving the state of the PAPR virtual
 PCI host bridge (or host bridges).
 
 I think the PCI cleanup patches I was working on need to go in before
 this, to make sure the migration stream pieces for PCI have same paths
 from the beginning.

We really want migration to go upstream... Are any close to get PCI
stuff upstream? I did not see updates for a while and could not find
anything new in your git on github.


-- 
With best regards

Alexey Kardashevskiy -- icq: 52150396



Re: [Qemu-devel] [PATCH 12/13] target-ppc: Add helper for KVM_PPC_RTAS_DEFINE_TOKEN

2013-06-05 Thread Alexey Kardashevskiy
On 05.06.2013 20:02, David Gibson wrote:
 On Tue, Jun 04, 2013 at 10:21:04PM +1000, Alexey Kardashevskiy wrote:
 From: David Gibson da...@gibson.dropbear.id.au

 Recent PowerKVM allows the kernel to intercept some RTAS calls from the
 guest directly.  This is used to implement the more efficient in-kernel
 XICS for example.  qemu is still responsible for assigning the RTAS token
 numbers however, and needs to tell the kernel which RTAS function name is
 assigned to a given token value.  This patch adds a convenience wrapper for
 the KVM_PPC_RTAS_DEFINE_TOKEN ioctl() which is used for this purpose.
 
 Um.. have you actually compiled this on ppc.  AFAICT, the necessary
 ioctl constant isn't yet imported into the mainline qemu tree.

Agrh. Yes, it compiles but headers need an update I suppose. I use the
ones from v3.10-rc2. I'll post headers update request tomorrow.


-- 
With best regards

Alexey Kardashevskiy -- icq: 52150396



Re: [Qemu-devel] [PATCH v5] net: add support of mac-programming over macvtap in QEMU side

2013-06-05 Thread Michael S. Tsirkin
On Wed, Jun 05, 2013 at 11:49:22AM +0100, Daniel P. Berrange wrote:
 On Wed, Jun 05, 2013 at 06:42:13PM +0800, Amos Kong wrote:
  Currently macvtap based macvlan device is working in promiscuous
  mode, we want to implement mac-programming over macvtap through
  Libvirt for better performance.
  
  Design:
  QEMU notifies Libvirt when rx-filter config is changed in guest,
  then Libvirt query the rx-filter information by a monitor command,
  and sync the change to macvtap device. Related rx-filter config
  of the nic contains main mac, rx-mode items and vlan table.
  
  This patch adds a QMP event to notify management of rx-filter change,
  and adds a monitor command for management to query rx-filter
  information.
  
  For reducing length of output, we just return the entries of vlan
  filter table that have active vlan.
  
  Event_throttle API can avoid the events to flood QMP client, but it
  could cause an unexpected delay. So a flag for each nic is used to
  avoid events flooding, if management doesn't query rx-filter after
  it receives one event, new events won't be emitted to QMP monitor.
  
  There maybe exist an uncontrollable delay if we let Libvirt do the
  real change, guests normally expect rx-filter updates immediately.
  But it's another separate issue, we can investigate it when the
  work in Libvirt side is done.
 
 What work is libvirt expected to do in response to these events ?
 It this just about updating the ebtables rules to allow packets
 with the newly configured MAC addr to be sent/received on the
 tap backend ?
 
 Daniel

For tap yes, but it depends on the backend.

For the macvtap backend, it needs to update the macvtap device mac(s)
and rx mode.

It also needs to be policy driven - some admins might want
to prevent the ability to change MAC for (some) guests.

 -- 
 |: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
 |: http://libvirt.org  -o- http://virt-manager.org :|
 |: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
 |: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|



Re: [Qemu-devel] [PATCH V13 6/6] hmp: add parameters device and -v for info block

2013-06-05 Thread Stefan Hajnoczi
On Sat, May 25, 2013 at 12:24:46PM +0800, Wenchao Xia wrote:
 diff --git a/hmp.c b/hmp.c
 index 2aa832c..a590ace 100644
 --- a/hmp.c
 +++ b/hmp.c
 @@ -279,10 +279,15 @@ void hmp_info_block(Monitor *mon, const QDict *qdict)
  {
  BlockInfoList *block_list, *info;
  ImageInfo *image_info;
 +const char *device = qdict_get_try_str(qdict, device);
 +int verbose = qdict_get_try_bool(qdict, verbose, 0);

bool verbose



Re: [Qemu-devel] [PATCH V13 0/6] enhancement for qmp/hmp interfaces of block info

2013-06-05 Thread Stefan Hajnoczi
On Sat, May 25, 2013 at 12:24:40PM +0800, Wenchao Xia wrote:
   This serial let qmp interface show delaied info, including internal snapshot
 /backing chain on all block device at runtime, which helps management stack 
 and
 human user, by retrieving exactly the same info of what qemu saws.
 
 Example:
 - { execute: query-block }
 - {
   return:[
  {
 io-status: ok,
 device:ide0-hd0,
 locked:false,
 removable:false,
 inserted:{
ro:false,
drv:qcow2,
encrypted:false,
file:disks/test.qcow2,
backing_file_depth:1,
bps:100,
bps_rd:0,
bps_wr:0,
iops:100,
iops_rd:0,
iops_wr:0,
image:{
   filename:disks/test.qcow2,
   format:qcow2,
   virtual-size:2048000,
   backing_file:base.qcow2,
   full-backing-filename:disks/base.qcow2,
   backing-filename-format:qcow2,
   snapshots:[
  {
 id: 1,
 name: snapshot1,
 vm-state-size: 0,
 date-sec: 1200,
 date-nsec: 12,
 vm-clock-sec: 206,
 vm-clock-nsec: 30
  }
   ],
   backing-image:{
   filename:disks/base.qcow2,
   format:qcow2,
   virtual-size:2048000
   }
}
 },
 type:unknown
  },
  {
 io-status: ok,
 device:ide1-cd0,
 locked:false,
 removable:true,
 type:unknown
  },
  {
 device:floppy0,
 locked:false,
 removable:true,
 type:unknown
  },
  {
 device:sd0,
 locked:false,
 removable:true,
 type:unknown
  }
   ]
}
 
   These patches follows the rule that use qmp to retieve information,
 hmp layer just does a translation from qmp object it got. To make code
 graceful, snapshot and image info retrieving code in qemu and qemu-img are
 merged into block layer, and some function name was adjusted to make it tips
 better. For the part touch by the serial, it works as:
 
qemu  qemu-img
 
 dump_monitordump_stdout
  |--| 
 |
block/qapi.c
 
   Special thanks for Markus, Stefan, Kevin, Eric reviewing many times.
 
 v13:
   Renamed the serial as enhancement for qmp/hmp interfaces of block info.
   Seperated the common part of code moving and hmp printf as a standalone
 serial, which can be used by both mine and Pavel's work. This serial depend
 on it: [PATCH V3 0/4] qapi and snapshot code clean up in block layer,
 https://lists.gnu.org/archive/html/qemu-devel/2013-05/msg03539.html
   Removed the VM snapshot info part, since it relate to VM snapshot creating
 logic, which should be changed together with Pavel's serial.
   Address Eric's comments:
   2/6: bdrv_query_image_info() returns void now, only use *errp to tip error.
 
 Wenchao Xia (6):
   1 block: add snapshot info query function bdrv_query_snapshot_info_list()
   2 block: add image info query function bdrv_query_image_info()
   3 qmp: add recursive member in ImageInfo
   4 qmp: add ImageInfo in BlockDeviceInfo used by query-block
   5 hmp: show ImageInfo in 'info block'
   6 hmp: add parameters device and -v for info block
 
  block/qapi.c |  148 
 ++
  hmp.c|   21 +++
  include/block/qapi.h |   14 +++--
  monitor.c|7 ++-
  qapi-schema.json |   10 +++-
  qemu-img.c   |   10 +++-
  qmp-commands.hx  |   69 +++-
  7 files changed, 242 insertions(+), 37 deletions(-)

I left comments but overall this looks very close to merge now.



Re: [Qemu-devel] [PATCH v2] linux-user: Allow getdents to be provided by getdents64

2013-06-05 Thread Peter Maydell
On 5 June 2013 11:57, Claudio Fontana claudio.font...@huawei.com wrote:
 On 04.06.2013 13:12, Peter Maydell wrote:
 Newer architectures may only implement the getdents64 syscall, not
 getdents. Provide an implementation of getdents in terms of getdents64
 so that we can run getdents-using targets on a getdents64-only host.

 I tested the change, and it works, however I get this during compilation:

 linux-user/syscall.c:382:12: warning: 'sys_futimesat' defined but not used 
 [-Wunused-function]

That's a separate issue : for that you want this patch:

http://patchwork.ozlabs.org/patch/248092/

thanks
-- PMM



Re: [Qemu-devel] [PATCH 00/39] Delay destruction of memory regions to instance_finalize

2013-06-05 Thread Michael S. Tsirkin
On Wed, Jun 05, 2013 at 11:50:52AM +0200, Andreas Färber wrote:
 Am 04.06.2013 20:51, schrieb Paolo Bonzini:
  This series changes all PCI devices (the sole to support hotplug
  _and_ use MemoryRegions) to do memory_region_del_subregion at
  unrealize time, and memory_region_destroy at instance_finalize
  time.
 
 The general idea looks good.
 
 Could you please follow-up with a patch that switches from exit to
 unrealize?

What do you guys think about changing the name to something
else e.g. free or destroy?

unrealize is not a word in english:
http://dictionary.cambridge.org/spellcheck/american-english/?q=unrealize

I can do it easily if people agree.

 use BUS(), PCI_DEVICE() etc. to hide this.
 
 Andreas
 
 -- 
 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
 GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCH 04/13] pseries: savevm support for XICS interrupt controller

2013-06-05 Thread Alexey Kardashevskiy
On 05.06.2013 19:55, David Gibson wrote:
 On Wed, Jun 05, 2013 at 01:22:02PM +1000, Alexey Kardashevskiy wrote:
 On 06/04/2013 10:20 PM, Alexey Kardashevskiy wrote:
 [snip]
 +static int ics_post_load(void *opaque, int version_id)
 +{
 +int i;
 +struct ics_state *ics = opaque;
 +
 +for (i = 0; i  ics-nr_irqs; i++) {

 Obviously here is a bug...

 -for (i = 0; i  ics-nr_irqs; i++) {
 +for (i = 0; i  ics-icp-nr_servers; i++) {
 
 Ah.. yes.  Although it would be a little nicer to avoid the duplicate
 calls to ics_resend() that will cause.  Still the simple version
 should be correct for now.  Please resend with this fixed.

I'll wait till Friday (do we expect anyone to comment, besides you?) and
repost the whole series with fixed from :)


-- 
With best regards

Alexey Kardashevskiy -- icq: 52150396



Re: [Qemu-devel] [PATCH 0/2] linux-user: Drop direct use of openat etc syscalls

2013-06-05 Thread Claudio Fontana
On 02.06.2013 00:35, Peter Maydell wrote:
 The linux-user syscall emulation layer currently supports the openat
 family of syscalls via two mechanisms: simply calling the corresponding
 libc functions, and making direct syscalls. Since glibc has supported
 these functions since at least glibc 2.5, there's no real need to
 retain the (essentially untested) direct syscall fallback code, so
 this patchset simply deletes it.
 
 This allows us to remove some ifdeffery that was attempting to disable
 provision of some of the syscalls if the host didn't seem to support
 them, which in some cases was actually wrong. For example where there
 are several flavours of the syscall, we only need one of them, not
 necessarily the exact one the guest has, as with the fstatat* calls.
 And if the guest needs the futimesat() syscall we can provide it
 via glibc, even if that syscall is deprecated or not provided in the
 host (because the host implements utimensat instead). AArch64 in
 particular hits the last of these, which resulted in a compile
 failure due to an unused function, because the syscall implementation's
 ifdef was inconsistent with the ifdef used to define the sys_futimesat()
 function.
 
 Basically, removing the ugly direct syscall access seemed nicer
 than trying to fix up and render consistent the broken ifdefs :-)
 
 [RHEL5 has glibc2.5 and provides these functions. RHEL4 did not
 but we don't build on RHEL4 anyhow because its glib is too old.
 uClibc provides these functions.]
 
 Peter Maydell (2):
   linux-user: Drop direct use of openat etc syscalls
   configure: Drop CONFIG_ATFILE test
 
  configure|   26 --
  linux-user/syscall.c |  218 
 ++
  2 files changed, 24 insertions(+), 220 deletions(-)
 

Tested on aarch64 with Foundation v8.

Tested-by: Claudio Fontana claudio.font...@huawei.com





Re: [Qemu-devel] [PATCH] target-ppc kvm: save cr register

2013-06-05 Thread David Gibson
On Wed, Jun 05, 2013 at 08:54:38PM +1000, Alexey Kardashevskiy wrote:
 On 05.06.2013 19:22, David Gibson wrote:
 
  I meant to post my pending patches at the end of last week, but was
  sidetracked by a minor injury :(.
 
  Sigh...
  What exactly are you going to post? PCI rework?
  
  Well until now the only thing I had in my ppc-next tree was the change
  of default machine. 
 
 btw what is going on with this patch?

I've pulled it into my github tree at
git://github.com/dgibson/qemu.git, ppc-next branch.  I'm still trying
to find time to push that out.

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


pgpb0rvx41TZT.pgp
Description: PGP signature


Re: [Qemu-devel] [PATCH v2] linux-user: Allow getdents to be provided by getdents64

2013-06-05 Thread Claudio Fontana
On 04.06.2013 13:12, Peter Maydell wrote:
 Newer architectures may only implement the getdents64 syscall, not
 getdents. Provide an implementation of getdents in terms of getdents64
 so that we can run getdents-using targets on a getdents64-only host.
 
 Signed-off-by: Peter Maydell peter.mayd...@linaro.org
 Message-id: 1370193044-24535-1-git-send-email-peter.mayd...@linaro.org
 ---
 Changes v1-v2:
  * memmove() call moved to before we write inode/offset/reclen
  * wrapped a stray long line that snuck in somehow
 
  linux-user/syscall.c |   61 
 +-
  1 file changed, 60 insertions(+), 1 deletion(-)
 
 diff --git a/linux-user/syscall.c b/linux-user/syscall.c
 index 0099d64..4151c78 100644
 --- a/linux-user/syscall.c
 +++ b/linux-user/syscall.c
 @@ -223,8 +223,11 @@ static int gettid(void) {
  return -ENOSYS;
  }
  #endif
 +#ifdef __NR_getdents
  _syscall3(int, sys_getdents, uint, fd, struct linux_dirent *, dirp, uint, 
 count);
 -#if defined(TARGET_NR_getdents64)  defined(__NR_getdents64)
 +#endif
 +#if !defined(__NR_getdents) || \
 +(defined(TARGET_NR_getdents64)  defined(__NR_getdents64))
  _syscall3(int, sys_getdents64, uint, fd, struct linux_dirent64 *, dirp, 
 uint, count);
  #endif
  #if defined(TARGET_NR__llseek)  defined(__NR_llseek)
 @@ -7123,6 +7126,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long 
 arg1,
  break;
  #endif
  case TARGET_NR_getdents:
 +#ifdef __NR_getdents
  #if TARGET_ABI_BITS == 32  HOST_LONG_BITS == 64
  {
  struct target_dirent *target_dirp;
 @@ -7195,6 +7199,61 @@ abi_long do_syscall(void *cpu_env, int num, abi_long 
 arg1,
  unlock_user(dirp, arg2, ret);
  }
  #endif
 +#else
 +/* Implement getdents in terms of getdents64 */
 +{
 +struct linux_dirent64 *dirp;
 +abi_long count = arg3;
 +
 +dirp = lock_user(VERIFY_WRITE, arg2, count, 0);
 +if (!dirp) {
 +goto efault;
 +}
 +ret = get_errno(sys_getdents64(arg1, dirp, count));
 +if (!is_error(ret)) {
 +/* Convert the dirent64 structs to target dirent.  We do this
 + * in-place, since we can guarantee that a target_dirent is 
 no
 + * larger than a dirent64; however this means we have to be
 + * careful to read everything before writing in the new 
 format.
 + */
 +struct linux_dirent64 *de;
 +struct target_dirent *tde;
 +int len = ret;
 +int tlen = 0;
 +
 +de = dirp;
 +tde = (struct target_dirent *)dirp;
 +while (len  0) {
 +int namelen, treclen;
 +int reclen = de-d_reclen;
 +uint64_t ino = de-d_ino;
 +int64_t off = de-d_off;
 +uint8_t type = de-d_type;
 +
 +namelen = strlen(de-d_name);
 +treclen = offsetof(struct target_dirent, d_name)
 ++ namelen + 2;
 +treclen = QEMU_ALIGN_UP(treclen, sizeof(abi_long));
 +
 +memmove(tde-d_name, de-d_name, namelen + 1);
 +tde-d_ino = tswapal(ino);
 +tde-d_off = tswapal(off);
 +tde-d_reclen = tswap16(treclen);
 +/* The target_dirent type is in what was formerly a 
 padding
 + * byte at the end of the structure:
 + */
 +*(((char *)tde) + treclen - 1) = type;
 +
 +de = (struct linux_dirent64 *)((char *)de + reclen);
 +tde = (struct target_dirent *)((char *)tde + treclen);
 +len -= reclen;
 +tlen += treclen;
 +}
 +ret = tlen;
 +}
 +unlock_user(dirp, arg2, ret);
 +}
 +#endif
  break;
  #if defined(TARGET_NR_getdents64)  defined(__NR_getdents64)
  case TARGET_NR_getdents64:
 

Tested on aarch64 Foundation v8

Tested-by: Claudio Fontana claudio.font...@huawei.com





Re: [Qemu-devel] [PATCH V2] net: tap: fix NULL dereference when passing invalid parameters to tap

2013-06-05 Thread Stefan Hajnoczi
On Tue, Jun 04, 2013 at 01:18:17PM +0800, Jason Wang wrote:
 This patch forbid the following invalid parameters to tap:
 
 1) fd and vhostfds were specified but vhostfd were not specified
 2) vhostfds were specified but fds were not specified
 3) fds and vhostfd were specified
 
 For 1 and 2, net_init_tap_one() will still pass NULL as vhostfdname to
 monitor_handle_fd_param(), which may crash the qemu.
 
 Also remove the unnecessary has_fd check.
 
 Cc: Paolo Bonzini pbonz...@redhat.com
 Cc: Stefan Hajnoczi shajn...@redhat.com
 Cc: Laszlo Ersek ler...@redhat.com
 Cc: qemu-sta...@nongnu.org
 Signed-off-by: Jason Wang jasow...@redhat.com
 
 ---
 Changes from v1:
 - check vhostfds for has_helper and all other cases
 - remove the unnecessary check for has_fd when fds were specified
 ---
  net/tap.c |   18 --
  1 files changed, 12 insertions(+), 6 deletions(-)

Thanks, applied to my net tree:
https://github.com/stefanha/qemu/commits/net

Stefan



Re: [Qemu-devel] qemu openpty

2013-06-05 Thread Andreas Färber
Am 05.06.2013 12:28, schrieb Michael Tokarev:
 Hello.
 
 One of old issues with compatibility between different
 *Nix systems was the way how pty pairs were allocated.
 
 And qemu have a twist in #includes, depending on which
 platform it is run, and quite some compat cruft in
 qemu-char.c about this issue.
 
 Here it is, from qemu-char.c:
 
 #ifdef __sun__
 /* Once Solaris has openpty(), this is going to be removed. */
 static int openpty(int *amaster, int *aslave, char *name,
struct termios *termp, struct winsize *winp)
 {...}
 
 static void cfmakeraw (struct termios *termios_p)
 {...}
 #endif
 
 and later on, openpty() is used in the code.  Note that
 both functions are marked as static - static to the
 source file, qemu-char.c.
 
 Now, we have ui/gtk.c, which calls openpty() and cfmakeraw()
 too, but this time, there's no compat alternative implementation
 provided.
 
 Does this mean we don't need the old compat implementation
 anymore?  Does gtk ui work (or at least builds) on solaris?

I haven't tried yet, but this sounds like something for osdep.c, no need
for a special qemu-openpty.c.

Andreas

 
 If gtk builds fine on solaris, it should be safe to remove
 these static functions from qemu-char.c.
 
 If not, we should obviously re-use these for ui/gtk.c --
 for which I'd create a new file, say, qemu-openpty.c,
 with all the system-dependent stuff inside, and create
 a wrapper function, qemu_openpty(), to do the work,
 and, ofcourse, remove pty.h and other fancy stuff
 (like stropts.h for solaris) from qemu-common.h (!!!)
 where it finally ended up.
 
 Thanks,
 
 /mjt
 


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



Re: [Qemu-devel] [PATCH v2] blockdev: reset werror/rerror on drive_del

2013-06-05 Thread Stefan Hajnoczi
On Wed, Jun 05, 2013 at 11:00:32AM +0200, Kevin Wolf wrote:
 Am 05.06.2013 um 10:33 hat Stefan Hajnoczi geschrieben:
  Paolo Bonzini pbonz...@redhat.com suggested the following test case:
  
  1. Launch a guest and wait at the GRUB boot menu:
  
qemu-system-x86_64 -enable-kvm -m 1024 \
 -drive if=none,cache=none,file=test.img,id=foo,werror=stop,rerror=stop
 -device virtio-blk-pci,drive=foo,id=virtio0,addr=4
  
  2. Hot unplug the device:
  
(qemu) drive_del foo
  
  3. Select the first boot menu entry
 
 Can we have a qtest or qemu-iotests version of this manual test case?

I will try to put something together.

Stefan



Re: [Qemu-devel] [PATCH 00/39] Delay destruction of memory regions to instance_finalize

2013-06-05 Thread Andreas Färber
Am 05.06.2013 13:10, schrieb Michael S. Tsirkin:
 On Wed, Jun 05, 2013 at 11:50:52AM +0200, Andreas Färber wrote:
 Am 04.06.2013 20:51, schrieb Paolo Bonzini:
 This series changes all PCI devices (the sole to support hotplug
 _and_ use MemoryRegions) to do memory_region_del_subregion at
 unrealize time, and memory_region_destroy at instance_finalize
 time.

 The general idea looks good.

 Could you please follow-up with a patch that switches from exit to
 unrealize?
 
 What do you guys think about changing the name to something
 else e.g. free or destroy?

I'm not generally opposed to renaming things, but current unrealize is a
pair with realize, and destroy or free doesn't really fit it's purpose -
that's instance_finalize. Let's CC Anthony.

Andreas

 
 unrealize is not a word in english:
 http://dictionary.cambridge.org/spellcheck/american-english/?q=unrealize
 
 I can do it easily if people agree.
 
 use BUS(), PCI_DEVICE() etc. to hide this.

 Andreas

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


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



Re: [Qemu-devel] [PATCH] virtio-net: fix wrong size of vlan filter table

2013-06-05 Thread Stefan Hajnoczi
On Wed, Jun 05, 2013 at 02:13:48PM +0800, Amos Kong wrote:
 The MAX_VLAN is 4096, currently the vlan filter table has 512
 (4096  3) entries, it's wrong.
 
 One entry in vlan filter table can indicate 32(1  5) vlans,
 so the table should have 128 (4096  5) entries.
 
 Signed-off-by: Amos Kong ak...@redhat.com
 ---
 btw, it would be simple to use an uint32 number to indicate
 all vlans (same as igbvf). I found e1000 uses the same table.
 Nothing needs to change here, it would cause migration issue.
 ---
  hw/net/virtio-net.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

I don't understand this patch.  memset() and qemu_put_buffer() work in
bytes, therefore MAX_VLAN  3.

MAX_VLAN  3 == MAX_VLAN / BITS_PER_BYTE
MAX_VLAN  5 == MAX_VLAN / (sizeof(uint32_t) * BITS_PER_BYTE)

What bug are you trying to fix?



Re: [Qemu-devel] [PATCH 00/39] Delay destruction of memory regions to instance_finalize

2013-06-05 Thread Peter Maydell
On 5 June 2013 12:10, Michael S. Tsirkin m...@redhat.com wrote:
 unrealize is not a word in english:

The OED says:
# unˈrealize, v.
# trans. To make unreal; to deprive of reality.

with the earliest citation from 1804.

so if it seems like the best term (and it does make
clear the pairing with realize, which I think is
a strong argument) we should go ahead and use it.

thanks
-- PMM



Re: [Qemu-devel] [PATCH v4 0/9] Make 'dump-guest-memory' dump in kdump-compressed format

2013-06-05 Thread Amos Kong
On Tue, Jun 04, 2013 at 10:15:41PM -0400, Luiz Capitulino wrote:
 
 [CC'ing Amos this time]
 
 On Wed, 05 Jun 2013 09:29:19 +0800
 Qiao Nuohan qiaonuo...@cn.fujitsu.com wrote:
 
I haven't reviewed it yet, but we need introspection support before 
  merging
this.
  
  Hello Luiz,
  
  Is it possible to get this reviewed, or I am supposed to wait until
  introspection support being settled?
 
 I can review it until the end of this week. If this series is adding a new
 argument (which I believe is what it does) then there's only two ways
 to get this merged: either we wait for full introspection or you add this
 feature as a new command.
 
 I'd prefer to wait for full introspection, but it depends how long it's
 going to take to get it merged and how much time you're willing to wait.
 
 Amos, can you give us an update on that work?


Summary of upstream discussion: 

 1) move events to schema.json, then it can also be introspected
(future work) (Luiz)
 2) need to support to return everyting in one shot (Eric)
 3) support filter by cmd/tyep/event name
 4) processe qapi-schema.json for a more explicit wire format
with metadata (Eric)
 5) dynamic schema (only for compiled/loaded modules) (Kevin)
 6) the real motivation behind full introspection is to allow
commands/enum/etc to be extended

I'm tring to implement my original throught, it's a little bit slow
because of the effect of other tasks. I will send the draft patch 
next week.

Amos.



Re: [Qemu-devel] [PATCH 00/39] Delay destruction of memory regions to instance_finalize

2013-06-05 Thread Michael S. Tsirkin
On Wed, Jun 05, 2013 at 12:38:35PM +0100, Peter Maydell wrote:
 On 5 June 2013 12:10, Michael S. Tsirkin m...@redhat.com wrote:
  unrealize is not a word in english:
 
 The OED says:
 # unˈrealize, v.
 # trans. To make unreal; to deprive of reality.
 
 with the earliest citation from 1804.
 
 so if it seems like the best term (and it does make
 clear the pairing with realize, which I think is
 a strong argument) we should go ahead and use it.
 
 thanks
 -- PMM

realize is a bad name too.

what does it mean? make real?
It's still all virtual ...

If we want it to mean hide from guest/expose to guest,
then why not call it like this?

expose_to_guest

unexpose_to_guest


finalize is even more ambigous, and not pairing
with anything as far as I could see.



-- 
MST



Re: [Qemu-devel] [PATCH 00/39] Delay destruction of memory regions to instance_finalize

2013-06-05 Thread Michael S. Tsirkin
On Wed, Jun 05, 2013 at 01:32:17PM +0200, Andreas Färber wrote:
 Am 05.06.2013 13:10, schrieb Michael S. Tsirkin:
  On Wed, Jun 05, 2013 at 11:50:52AM +0200, Andreas Färber wrote:
  Am 04.06.2013 20:51, schrieb Paolo Bonzini:
  This series changes all PCI devices (the sole to support hotplug
  _and_ use MemoryRegions) to do memory_region_del_subregion at
  unrealize time, and memory_region_destroy at instance_finalize
  time.
 
  The general idea looks good.
 
  Could you please follow-up with a patch that switches from exit to
  unrealize?
  
  What do you guys think about changing the name to something
  else e.g. free or destroy?
 
 I'm not generally opposed to renaming things, but current unrealize is a
 pair with realize, and destroy or free doesn't really fit it's purpose -
 that's instance_finalize. Let's CC Anthony.
 
 Andreas

So @instance_init - instance_alloc
instance_finalize - @instance_free?



  
  unrealize is not a word in english:
  http://dictionary.cambridge.org/spellcheck/american-english/?q=unrealize
  
  I can do it easily if people agree.
  
  use BUS(), PCI_DEVICE() etc. to hide this.
 
  Andreas
 
  -- 
  SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
  GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
 
 
 -- 
 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
 GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



[Qemu-devel] [BACKPORT qemu-xen 0/3] fixes for 4.3

2013-06-05 Thread Stefano Stabellini
Hi all,
this patch series backports few fixes from QEMU to qemu-xen 4.3.


The second patch avoid calling main_loop_wait with nonblocking set to 1,
so that the select timeout is always as high as possible on Xen.

The third patch fixes this PCI passthrough bug:
http://marc.info/?l=xen-develm=136242365010750


Stefano Stabellini (3):
  xen: simplify xen_enabled
  main_loop: do not set nonblocking if xen_enabled()
  xen: start PCI hole at 0xe000 (same as pc_init1 and 
qemu-xen-traditional)

 hw/pc.h  |3 +++
 hw/pc_piix.c |6 +++---
 hw/xen.h |4 
 vl.c |2 +-
 xen-all.c|   12 ++--
 5 files changed, 13 insertions(+), 14 deletions(-)

Cheers,

Stefano



[Qemu-devel] [BACKPORT qemu-xen 1/3] xen: simplify xen_enabled

2013-06-05 Thread Stefano Stabellini
No need for preprocessor conditionals in xen_enabled: xen_allowed is
always defined.

upstream-commit-id: 49fa9881b2358e390e9e9466ddde74e995927efa

Signed-off-by: Stefano Stabellini stefano.stabell...@eu.citrix.com
---
 hw/xen.h |4 
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/hw/xen.h b/hw/xen.h
index e3cca7f..dd46db9 100644
--- a/hw/xen.h
+++ b/hw/xen.h
@@ -25,11 +25,7 @@ extern int xen_allowed;
 
 static inline int xen_enabled(void)
 {
-#if defined(CONFIG_XEN_BACKEND)  !defined(CONFIG_NO_XEN)
 return xen_allowed;
-#else
-return 0;
-#endif
 }
 
 int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num);
-- 
1.7.2.5




[Qemu-devel] [BACKPORT qemu-xen 2/3] main_loop: do not set nonblocking if xen_enabled()

2013-06-05 Thread Stefano Stabellini
upstream-commit-id: a7d4207d378069a5bb3175a131e8fdedd39ef97d

Signed-off-by: Stefano Stabellini stefano.stabell...@eu.citrix.com
---
 vl.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/vl.c b/vl.c
index a3ab384..5314f55 100644
--- a/vl.c
+++ b/vl.c
@@ -1763,7 +1763,7 @@ static void main_loop(void)
 int64_t ti;
 #endif
 do {
-nonblocking = !kvm_enabled()  last_io  0;
+nonblocking = !kvm_enabled()  !xen_enabled()  last_io  0;
 #ifdef CONFIG_PROFILER
 ti = profile_getclock();
 #endif
-- 
1.7.2.5




[Qemu-devel] [BACKPORT qemu-xen 3/3] xen: start PCI hole at 0xe0000000 (same as pc_init1 and qemu-xen-traditional)

2013-06-05 Thread Stefano Stabellini
We are currently setting the PCI hole to start at HVM_BELOW_4G_RAM_END,
that is 0xf000.
Start the PCI hole at 0xe000 instead, that is the same value used by
pc_init1 and qemu-xen-traditional.

upstream-commit-id: 9f24a8030a70ea4954b5b8c48f606012f086f65f

Signed-off-by: Stefano Stabellini stefano.stabell...@eu.citrix.com
---
 hw/pc.h  |3 +++
 hw/pc_piix.c |6 +++---
 xen-all.c|   12 ++--
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/hw/pc.h b/hw/pc.h
index 2237e86..30856a2 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -78,6 +78,9 @@ extern int fd_bootchk;
 void pc_register_ferr_irq(qemu_irq irq);
 void pc_acpi_smi_interrupt(void *opaque, int irq, int level);
 
+#define QEMU_BELOW_4G_RAM_END   0xe000
+#define QEMU_BELOW_4G_MMIO_LENGTH   ((1ULL  32) - QEMU_BELOW_4G_RAM_END)
+
 void pc_cpus_init(const char *cpu_model);
 void *pc_memory_init(MemoryRegion *system_memory,
 const char *kernel_filename,
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index aa3e7f4..711a22d 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -92,9 +92,9 @@ static void pc_init1(MemoryRegion *system_memory,
 kvmclock_create();
 }
 
-if (ram_size = 0xe000 ) {
-above_4g_mem_size = ram_size - 0xe000;
-below_4g_mem_size = 0xe000;
+if (ram_size = QEMU_BELOW_4G_RAM_END ) {
+above_4g_mem_size = ram_size - QEMU_BELOW_4G_RAM_END;
+below_4g_mem_size = QEMU_BELOW_4G_RAM_END;
 } else {
 above_4g_mem_size = 0;
 below_4g_mem_size = ram_size;
diff --git a/xen-all.c b/xen-all.c
index daf43b9..d5a2edc 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -160,18 +160,18 @@ static void xen_ram_init(ram_addr_t ram_size)
 ram_addr_t block_len;
 
 block_len = ram_size;
-if (ram_size = HVM_BELOW_4G_RAM_END) {
+if (ram_size = QEMU_BELOW_4G_RAM_END) {
 /* Xen does not allocate the memory continuously, and keep a hole at
- * HVM_BELOW_4G_MMIO_START of HVM_BELOW_4G_MMIO_LENGTH
+ * QEMU_BELOW_4G_RAM_END of QEMU_BELOW_4G_MMIO_LENGTH
  */
-block_len += HVM_BELOW_4G_MMIO_LENGTH;
+block_len += QEMU_BELOW_4G_MMIO_LENGTH;
 }
 memory_region_init_ram(ram_memory, xen.ram, block_len);
 vmstate_register_ram_global(ram_memory);
 
-if (ram_size = HVM_BELOW_4G_RAM_END) {
-above_4g_mem_size = ram_size - HVM_BELOW_4G_RAM_END;
-below_4g_mem_size = HVM_BELOW_4G_RAM_END;
+if (ram_size = QEMU_BELOW_4G_RAM_END) {
+above_4g_mem_size = ram_size - QEMU_BELOW_4G_RAM_END;
+below_4g_mem_size = QEMU_BELOW_4G_RAM_END;
 } else {
 below_4g_mem_size = ram_size;
 }
-- 
1.7.2.5




Re: [Qemu-devel] [PATCH 00/39] Delay destruction of memory regions to instance_finalize

2013-06-05 Thread Michael S. Tsirkin
On Wed, Jun 05, 2013 at 12:38:35PM +0100, Peter Maydell wrote:
 On 5 June 2013 12:10, Michael S. Tsirkin m...@redhat.com wrote:
  unrealize is not a word in english:
 
 The OED says:
 # unˈrealize, v.
 # trans. To make unreal; to deprive of reality.
 
 with the earliest citation from 1804.

So someone somewhere uses it like this once.
It's still a bad idea to use uncommon words,
it won't be in a dictionary of non-native english speakers
and attempts to look it up in online dictionaries fail
to return useful info.

Documentation also talks about Realization as a process
of making real.

You are going to say someone used it like that in the 19th century?

It does not change the fact that realize means understand in
the most common meaning of this word.
include/hw/qdev-core.h also uses the term Realization.

Again for most people Realization means becoming aware of
http://oxforddictionaries.com/definition/english/realization?q=Realization

So at least, this is ambigous.

Can we use terms which are less ambigous?

 so if it seems like the best term (and it does make
 clear the pairing with realize, which I think is
 a strong argument) we should go ahead and use it.
 
 thanks
 -- PMM



[Qemu-devel] [PATCH v2 01/16] qemu-io: Remove unused args_command

2013-06-05 Thread Kevin Wolf
The original intention seems to be something with handling multiple
images at once, but this has never been implemented and the only
function ever registered is implemented to make everything behave like a
global command. Just do that unconditionally now.

Signed-off-by: Kevin Wolf kw...@redhat.com
Reviewed-by: Eric Blake ebl...@redhat.com
---
 cmd.c | 28 ++--
 cmd.h |  2 --
 qemu-io.c | 10 --
 3 files changed, 2 insertions(+), 38 deletions(-)

diff --git a/cmd.c b/cmd.c
index 10a8688..4e7579b 100644
--- a/cmd.c
+++ b/cmd.c
@@ -34,7 +34,6 @@
 cmdinfo_t  *cmdtab;
 intncmds;
 
-static argsfunc_t  args_func;
 static checkfunc_t check_func;
 static int ncmdline;
 static char**cmdline;
@@ -127,22 +126,6 @@ void add_user_command(char *optarg)
 cmdline[ncmdline-1] = optarg;
 }
 
-static int
-args_command(
-   int index)
-{
-   if (args_func)
-   return args_func(index);
-   return 0;
-}
-
-void
-add_args_command(
-   argsfunc_t  af)
-{
-   args_func = af;
-}
-
 static void prep_fetchline(void *opaque)
 {
 int *fetchable = opaque;
@@ -155,7 +138,7 @@ static char *get_prompt(void);
 
 void command_loop(void)
 {
-int c, i, j = 0, done = 0, fetchable = 0, prompted = 0;
+int c, i, done = 0, fetchable = 0, prompted = 0;
 char *input;
 char **v;
 const cmdinfo_t *ct;
@@ -171,14 +154,7 @@ void command_loop(void)
 if (c) {
 ct = find_command(v[0]);
 if (ct) {
-if (ct-flags  CMD_FLAG_GLOBAL) {
-done = command(ct, c, v);
-} else {
-j = 0;
-while (!done  (j = args_command(j))) {
-done = command(ct, c, v);
-}
-}
+done = command(ct, c, v);
 } else {
 fprintf(stderr, _(command \%s\ not found\n), v[0]);
 }
diff --git a/cmd.h b/cmd.h
index b763b19..8e6f753 100644
--- a/cmd.h
+++ b/cmd.h
@@ -41,12 +41,10 @@ extern int  ncmds;
 void help_init(void);
 void quit_init(void);
 
-typedef int (*argsfunc_t)(int index);
 typedef int (*checkfunc_t)(const cmdinfo_t *ci);
 
 void add_command(const cmdinfo_t *ci);
 void add_user_command(char *optarg);
-void add_args_command(argsfunc_t af);
 void add_check_command(checkfunc_t cf);
 
 const cmdinfo_t *find_command(const char *cmd);
diff --git a/qemu-io.c b/qemu-io.c
index 5e6680b..4288b8c 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -1888,15 +1888,6 @@ static int open_f(int argc, char **argv)
 return openfile(argv[optind], flags, growable);
 }
 
-static int init_args_command(int index)
-{
-/* only one device allowed so far */
-if (index = 1) {
-return 0;
-}
-return ++index;
-}
-
 static int init_check_command(const cmdinfo_t *ct)
 {
 if (ct-flags  CMD_FLAG_GLOBAL) {
@@ -2043,7 +2034,6 @@ int main(int argc, char **argv)
 add_command(wait_break_cmd);
 add_command(abort_cmd);
 
-add_args_command(init_args_command);
 add_check_command(init_check_command);
 
 /* open the device */
-- 
1.8.1.4




[Qemu-devel] [PATCH v2 02/16] cutils: Support 'P' and 'E' suffixes in strtosz()

2013-06-05 Thread Kevin Wolf
Signed-off-by: Kevin Wolf kw...@redhat.com
Reviewed-by: Eric Blake ebl...@redhat.com
---
 include/qemu-common.h  |  2 ++
 monitor.c  |  8 
 qemu-img.c | 10 ++
 tests/qemu-iotests/049.out |  8 
 util/cutils.c  |  4 
 5 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/include/qemu-common.h b/include/qemu-common.h
index cb82ef3..d95ea1e 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -191,6 +191,8 @@ int parse_uint_full(const char *s, unsigned long long 
*value, int base);
  * A-Z, as strtosz() will use qemu_toupper() on the given argument
  * prior to comparison.
  */
+#define STRTOSZ_DEFSUFFIX_EB   'E'
+#define STRTOSZ_DEFSUFFIX_PB   'P'
 #define STRTOSZ_DEFSUFFIX_TB   'T'
 #define STRTOSZ_DEFSUFFIX_GB   'G'
 #define STRTOSZ_DEFSUFFIX_MB   'M'
diff --git a/monitor.c b/monitor.c
index eefc7f0..9d279b8 100644
--- a/monitor.c
+++ b/monitor.c
@@ -93,10 +93,10 @@
  * 'M'  Non-negative target long (32 or 64 bit), in user mode the
  *  value is multiplied by 2^20 (think Mebibyte)
  * 'o'  octets (aka bytes)
- *  user mode accepts an optional T, t, G, g, M, m, K, k
- *  suffix, which multiplies the value by 2^40 for
- *  suffixes T and t, 2^30 for suffixes G and g, 2^20 for
- *  M and m, 2^10 for K and k
+ *  user mode accepts an optional E, e, P, p, T, t, G, g, M, m,
+ *  K, k suffix, which multiplies the value by 2^60 for suffixes E
+ *  and e, 2^50 for suffixes P and p, 2^40 for suffixes T and t,
+ *  2^30 for suffixes G and g, 2^20 for M and m, 2^10 for K and k
  * 'T'  double
  *  user mode accepts an optional ms, us, ns suffix,
  *  which divides the value by 1e3, 1e6, 1e9, respectively
diff --git a/qemu-img.c b/qemu-img.c
index 5aba409..bdb5ead 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -85,8 +85,9 @@ static void help(void)
options are: 'none', 'writeback' (default, except for 
convert), 'writethrough',\n
'directsync' and 'unsafe' (default for convert)\n
  'size' is the disk image size in bytes. Optional suffixes\n
-   'k' or 'K' (kilobyte, 1024), 'M' (megabyte, 1024k), 'G' 
(gigabyte, 1024M)\n
-   and T (terabyte, 1024G) are supported. 'b' is ignored.\n
+   'k' or 'K' (kilobyte, 1024), 'M' (megabyte, 1024k), 'G' 
(gigabyte, 1024M),\n
+   'T' (terabyte, 1024G), 'P' (petabyte, 1024T) and 'E' (exabyte, 
1024P)  are\n
+   supported. 'b' is ignored.\n
  'output_filename' is the destination disk image filename\n
  'output_fmt' is the destination format\n
  'options' is a comma separated list of format specific options 
in a\n
@@ -387,8 +388,9 @@ static int img_create(int argc, char **argv)
 error_report(Image size must be less than 8 EiB!);
 } else {
 error_report(Invalid image size specified! You may use k, M, 
-  G or T suffixes for );
-error_report(kilobytes, megabytes, gigabytes and terabytes.);
+  G, T, P or E suffixes for );
+error_report(kilobytes, megabytes, gigabytes, terabytes, 
+ petabytes and exabytes.);
 }
 return 1;
 }
diff --git a/tests/qemu-iotests/049.out b/tests/qemu-iotests/049.out
index 72db13f..d2f0efe 100644
--- a/tests/qemu-iotests/049.out
+++ b/tests/qemu-iotests/049.out
@@ -108,15 +108,15 @@ qemu-img: Formatting or formatting option not supported 
for file format 'qcow2'
 Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=-1024 encryption=off 
cluster_size=65536 lazy_refcounts=off 
 
 qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- 1kilobyte
-qemu-img: Invalid image size specified! You may use k, M, G or T suffixes for 
-qemu-img: kilobytes, megabytes, gigabytes and terabytes.
+qemu-img: Invalid image size specified! You may use k, M, G, T, P or E 
suffixes for 
+qemu-img: kilobytes, megabytes, gigabytes, terabytes, petabytes and exabytes.
 
 qemu-img create -f qcow2 -o size=1kilobyte TEST_DIR/t.qcow2
 Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 encryption=off 
cluster_size=65536 lazy_refcounts=off 
 
 qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- foobar
-qemu-img: Invalid image size specified! You may use k, M, G or T suffixes for 
-qemu-img: kilobytes, megabytes, gigabytes and terabytes.
+qemu-img: Invalid image size specified! You may use k, M, G, T, P or E 
suffixes for 
+qemu-img: kilobytes, megabytes, gigabytes, terabytes, petabytes and exabytes.
 
 qemu-img create -f qcow2 -o size=foobar TEST_DIR/t.qcow2
 qemu-img: Parameter 'size' expects a size
diff --git a/util/cutils.c b/util/cutils.c
index a165819..8f28896 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -267,6 +267,10 @@ static int64_t suffix_mul(char 

[Qemu-devel] [PATCH v2 00/16] Make qemu-io commands available in the monitor

2013-06-05 Thread Kevin Wolf
This is a prerequisite for some kind of tests. It involves reorganising the
qemu-io code so that the command part can be separated and doesn't pollute the
global namespace any more, so we can link it with qemu.

v2:
- Drop the QMP command, make it HMP only
- Minor review comments like typos

Kevin Wolf (16):
  qemu-io: Remove unused args_command
  cutils: Support 'P' and 'E' suffixes in strtosz()
  qemu-io: Make cvtnum() a wrapper around strtosz_suffix()
  qemu-io: Handle cvtnum() errors in 'alloc'
  qemu-io: Don't use global bs in command implementations
  qemu-io: Split off commands to qemu-io-cmds.c
  qemu-io: Factor out qemuio_command
  qemu-io: Move 'help' function
  qemu-io: Move 'quit' function
  qemu-io: Move qemu_strsep() to cutils.c
  qemu-io: Move functions for registering and running commands
  qemu-io: Move command_loop() and friends
  qemu-io: Move remaining helpers from cmd.c
  qemu-io: Interface cleanup
  qemu-io: Use the qemu version for -V
  Make qemu-io commands available in HMP

 Makefile   |2 +-
 Makefile.objs  |1 +
 cmd.c  |  612 -
 cmd.h  |   79 --
 hmp-commands.hx|   16 +
 hmp.c  |   18 +
 hmp.h  |1 +
 include/qemu-common.h  |3 +
 include/qemu-io.h  |   46 +
 monitor.c  |8 +-
 qemu-img.c |   10 +-
 qemu-io-cmds.c | 2118 
 qemu-io.c  | 1990 -
 tests/qemu-iotests/049.out |8 +-
 util/cutils.c  |   25 +
 15 files changed, 2416 insertions(+), 2521 deletions(-)
 delete mode 100644 cmd.c
 delete mode 100644 cmd.h
 create mode 100644 include/qemu-io.h
 create mode 100644 qemu-io-cmds.c

-- 
1.8.1.4




[Qemu-devel] [PATCH v2 03/16] qemu-io: Make cvtnum() a wrapper around strtosz_suffix()

2013-06-05 Thread Kevin Wolf
No reason to implement the same thing multiple times. A nice side effect
is that fractional numbers like 0.5M can be used in qemu-io now.

Signed-off-by: Kevin Wolf kw...@redhat.com
Reviewed-by: Eric Blake ebl...@redhat.com
---
 cmd.c | 37 -
 cmd.h |  1 -
 qemu-io.c |  6 ++
 3 files changed, 6 insertions(+), 38 deletions(-)

diff --git a/cmd.c b/cmd.c
index 4e7579b..214c6f7 100644
--- a/cmd.c
+++ b/cmd.c
@@ -344,43 +344,6 @@ doneline(
 #define MEGABYTES(x)   ((long long)(x)  20)
 #define KILOBYTES(x)   ((long long)(x)  10)
 
-long long
-cvtnum(
-   char*s)
-{
-   long long   i;
-   char*sp;
-   int c;
-
-   i = strtoll(s, sp, 0);
-   if (i == 0  sp == s)
-   return -1LL;
-   if (*sp == '\0')
-   return i;
-
-   if (sp[1] != '\0')
-   return -1LL;
-
-   c = qemu_tolower(*sp);
-   switch (c) {
-   default:
-   return i;
-   case 'k':
-   return KILOBYTES(i);
-   case 'm':
-   return MEGABYTES(i);
-   case 'g':
-   return GIGABYTES(i);
-   case 't':
-   return TERABYTES(i);
-   case 'p':
-   return PETABYTES(i);
-   case 'e':
-   return  EXABYTES(i);
-   }
-   return -1LL;
-}
-
 #define TO_EXABYTES(x) ((x) / EXABYTES(1))
 #define TO_PETABYTES(x)((x) / PETABYTES(1))
 #define TO_TERABYTES(x)((x) / TERABYTES(1))
diff --git a/cmd.h b/cmd.h
index 8e6f753..4dcfe88 100644
--- a/cmd.h
+++ b/cmd.h
@@ -58,7 +58,6 @@ char **breakline(char *input, int *count);
 void doneline(char *input, char **vec);
 char *fetchline(void);
 
-long long cvtnum(char *s);
 void cvtstr(double value, char *str, size_t sz);
 
 struct timeval tsub(struct timeval t1, struct timeval t2);
diff --git a/qemu-io.c b/qemu-io.c
index 4288b8c..8a719a8 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -29,6 +29,12 @@ static BlockDriverState *bs;
 
 static int misalign;
 
+static int64_t cvtnum(const char *s)
+{
+char *end;
+return strtosz_suffix(s, end, STRTOSZ_DEFSUFFIX_B);
+}
+
 /*
  * Parse the pattern argument to various sub-commands.
  *
-- 
1.8.1.4




[Qemu-devel] [PATCH v2 04/16] qemu-io: Handle cvtnum() errors in 'alloc'

2013-06-05 Thread Kevin Wolf
Signed-off-by: Kevin Wolf kw...@redhat.com
Reviewed-by: Eric Blake ebl...@redhat.com
---
 qemu-io.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/qemu-io.c b/qemu-io.c
index 8a719a8..b4f56fc 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -1596,7 +1596,10 @@ static int alloc_f(int argc, char **argv)
 int ret;
 
 offset = cvtnum(argv[1]);
-if (offset  0x1ff) {
+if (offset  0) {
+printf(non-numeric offset argument -- %s\n, argv[1]);
+return 0;
+} else if (offset  0x1ff) {
 printf(offset % PRId64  is not sector aligned\n,
offset);
 return 0;
@@ -1604,6 +1607,10 @@ static int alloc_f(int argc, char **argv)
 
 if (argc == 3) {
 nb_sectors = cvtnum(argv[2]);
+if (nb_sectors  0) {
+printf(non-numeric length argument -- %s\n, argv[2]);
+return 0;
+}
 } else {
 nb_sectors = 1;
 }
-- 
1.8.1.4




[Qemu-devel] [PATCH v2 15/16] qemu-io: Use the qemu version for -V

2013-06-05 Thread Kevin Wolf
Always printing 0.0.1 and never updating the version number wasn't very
useful. qemu-io is released with qemu, so using the same version number
makes most sense.

Signed-off-by: Kevin Wolf kw...@redhat.com
---
 qemu-io.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/qemu-io.c b/qemu-io.c
index 514edcb..cb9def5 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -19,8 +19,6 @@
 #include block/block_int.h
 #include trace/control.h
 
-#define VERSION0.0.1
-
 #define CMD_NOFILE_OK   0x01
 
 char *progname;
@@ -380,7 +378,7 @@ int main(int argc, char **argv)
 }
 break;
 case 'V':
-printf(%s version %s\n, progname, VERSION);
+printf(%s version %s\n, progname, QEMU_VERSION);
 exit(0);
 case 'h':
 usage(progname);
-- 
1.8.1.4




[Qemu-devel] [PATCH v2 11/16] qemu-io: Move functions for registering and running commands

2013-06-05 Thread Kevin Wolf
Signed-off-by: Kevin Wolf kw...@redhat.com
Reviewed-by: Eric Blake ebl...@redhat.com
---
 cmd.c  | 113 -
 cmd.h  |  11 +---
 qemu-io-cmds.c | 192 ++---
 qemu-io.c  |  10 +--
 4 files changed, 148 insertions(+), 178 deletions(-)

diff --git a/cmd.c b/cmd.c
index f6bf2c5..6616d61 100644
--- a/cmd.c
+++ b/cmd.c
@@ -31,94 +31,9 @@
 
 /* from libxcmd/command.c */
 
-cmdinfo_t  *cmdtab;
-intncmds;
-
-static checkfunc_t check_func;
 static int ncmdline;
 static char**cmdline;
 
-static int
-compare(const void *a, const void *b)
-{
-   return strcmp(((const cmdinfo_t *)a)-name,
- ((const cmdinfo_t *)b)-name);
-}
-
-void add_command(const cmdinfo_t *ci)
-{
-cmdtab = g_realloc((void *)cmdtab, ++ncmds * sizeof(*cmdtab));
-cmdtab[ncmds - 1] = *ci;
-qsort(cmdtab, ncmds, sizeof(*cmdtab), compare);
-}
-
-static int
-check_command(
-   const cmdinfo_t *ci)
-{
-   if (check_func)
-   return check_func(qemuio_bs, ci);
-   return 1;
-}
-
-void
-add_check_command(
-   checkfunc_t cf)
-{
-   check_func = cf;
-}
-
-int
-command_usage(
-   const cmdinfo_t *ci)
-{
-   printf(%s %s -- %s\n, ci-name, ci-args, ci-oneline);
-   return 0;
-}
-
-int
-command(
-   const cmdinfo_t *ct,
-   int argc,
-   char**argv)
-{
-   char*cmd = argv[0];
-
-   if (!check_command(ct))
-   return 0;
-
-   if (argc-1  ct-argmin || (ct-argmax != -1  argc-1  ct-argmax)) {
-   if (ct-argmax == -1)
-   fprintf(stderr,
-   _(bad argument count %d to %s, expected at least %d arguments\n),
-   argc-1, cmd, ct-argmin);
-   else if (ct-argmin == ct-argmax)
-   fprintf(stderr,
-   _(bad argument count %d to %s, expected %d arguments\n),
-   argc-1, cmd, ct-argmin);
-   else
-   fprintf(stderr,
-   _(bad argument count %d to %s, expected between %d and %d 
arguments\n),
-   argc-1, cmd, ct-argmin, ct-argmax);
-   return 0;
-   }
-   optind = 0;
-   return ct-cfunc(qemuio_bs, argc, argv);
-}
-
-const cmdinfo_t *
-find_command(
-   const char  *cmd)
-{
-   cmdinfo_t   *ct;
-
-   for (ct = cmdtab; ct  cmdtab[ncmds]; ct++) {
-   if (strcmp(ct-name, cmd) == 0 ||
-   (ct-altname  strcmp(ct-altname, cmd) == 0))
-   return (const cmdinfo_t *)ct;
-   }
-   return NULL;
-}
 
 void add_user_command(char *optarg)
 {
@@ -255,34 +170,6 @@ fetchline(void)
 }
 #endif
 
-char **breakline(char *input, int *count)
-{
-int c = 0;
-char *p;
-char **rval = calloc(sizeof(char *), 1);
-char **tmp;
-
-while (rval  (p = qemu_strsep(input,  )) != NULL) {
-if (!*p) {
-continue;
-}
-c++;
-tmp = realloc(rval, sizeof(*rval) * (c + 1));
-if (!tmp) {
-free(rval);
-rval = NULL;
-c = 0;
-break;
-} else {
-rval = tmp;
-}
-rval[c - 1] = p;
-rval[c] = NULL;
-}
-*count = c;
-return rval;
-}
-
 #define EXABYTES(x)((long long)(x)  60)
 #define PETABYTES(x)   ((long long)(x)  50)
 #define TERABYTES(x)   ((long long)(x)  40)
diff --git a/cmd.h b/cmd.h
index 5b6f61b..0d01a33 100644
--- a/cmd.h
+++ b/cmd.h
@@ -39,23 +39,16 @@ typedef struct cmdinfo {
helpfunc_t  help;
 } cmdinfo_t;
 
-extern cmdinfo_t   *cmdtab;
-extern int ncmds;
-
 typedef int (*checkfunc_t)(BlockDriverState *bs, const cmdinfo_t *ci);
 
-void add_command(const cmdinfo_t *ci);
+void qemuio_add_command(const cmdinfo_t *ci);
 void add_user_command(char *optarg);
 void add_check_command(checkfunc_t cf);
 
-const cmdinfo_t *find_command(const char *cmd);
-
 void command_loop(void);
-int command_usage(const cmdinfo_t *ci);
-int command(const cmdinfo_t *ci, int argc, char **argv);
+int qemuio_command_usage(const cmdinfo_t *ci);
 
 /* from input.h */
-char **breakline(char *input, int *count);
 char *fetchline(void);
 
 void cvtstr(double value, char *str, size_t sz);
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index fa8d9a0..8acc866 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -16,6 +16,110 @@
 
 int qemuio_misalign;
 
+static cmdinfo_t *cmdtab;
+static int ncmds;
+
+static int compare_cmdname(const void *a, const void *b)
+{
+return strcmp(((const cmdinfo_t *)a)-name,
+  ((const cmdinfo_t *)b)-name);
+}
+
+void qemuio_add_command(const cmdinfo_t *ci)
+{
+cmdtab = g_realloc(cmdtab, ++ncmds * sizeof(*cmdtab));
+cmdtab[ncmds - 1] = *ci;
+qsort(cmdtab, ncmds, sizeof(*cmdtab), compare_cmdname);
+}
+
+int 

[Qemu-devel] [PATCH v2 10/16] qemu-io: Move qemu_strsep() to cutils.c

2013-06-05 Thread Kevin Wolf
Signed-off-by: Kevin Wolf kw...@redhat.com
Reviewed-by: Eric Blake ebl...@redhat.com
---
 cmd.c | 21 -
 include/qemu-common.h |  1 +
 util/cutils.c | 21 +
 3 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/cmd.c b/cmd.c
index 8496e74..f6bf2c5 100644
--- a/cmd.c
+++ b/cmd.c
@@ -255,27 +255,6 @@ fetchline(void)
 }
 #endif
 
-static char *qemu_strsep(char **input, const char *delim)
-{
-char *result = *input;
-if (result != NULL) {
-char *p;
-
-for (p = result; *p != '\0'; p++) {
-if (strchr(delim, *p)) {
-break;
-}
-}
-if (*p == '\0') {
-*input = NULL;
-} else {
-*p = '\0';
-*input = p + 1;
-}
-}
-return result;
-}
-
 char **breakline(char *input, int *count)
 {
 int c = 0;
diff --git a/include/qemu-common.h b/include/qemu-common.h
index d95ea1e..ed8b6e2 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -174,6 +174,7 @@ char *pstrcat(char *buf, int buf_size, const char *s);
 int strstart(const char *str, const char *val, const char **ptr);
 int stristart(const char *str, const char *val, const char **ptr);
 int qemu_strnlen(const char *s, int max_len);
+char *qemu_strsep(char **input, const char *delim);
 time_t mktimegm(struct tm *tm);
 int qemu_fls(int i);
 int qemu_fdatasync(int fd);
diff --git a/util/cutils.c b/util/cutils.c
index 8f28896..0116fcd 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -107,6 +107,27 @@ int qemu_strnlen(const char *s, int max_len)
 return i;
 }
 
+char *qemu_strsep(char **input, const char *delim)
+{
+char *result = *input;
+if (result != NULL) {
+char *p;
+
+for (p = result; *p != '\0'; p++) {
+if (strchr(delim, *p)) {
+break;
+}
+}
+if (*p == '\0') {
+*input = NULL;
+} else {
+*p = '\0';
+*input = p + 1;
+}
+}
+return result;
+}
+
 time_t mktimegm(struct tm *tm)
 {
 time_t t;
-- 
1.8.1.4




[Qemu-devel] [PATCH v2 13/16] qemu-io: Move remaining helpers from cmd.c

2013-06-05 Thread Kevin Wolf
Signed-off-by: Kevin Wolf kw...@redhat.com
---
 Makefile   |   2 +-
 cmd.c  | 139 -
 cmd.h  |  14 --
 qemu-io-cmds.c | 104 ++
 4 files changed, 105 insertions(+), 154 deletions(-)
 delete mode 100644 cmd.c

diff --git a/Makefile b/Makefile
index cf932eb..87298e5 100644
--- a/Makefile
+++ b/Makefile
@@ -186,7 +186,7 @@ qemu-img.o: qemu-img-cmds.h
 
 qemu-img$(EXESUF): qemu-img.o $(block-obj-y) libqemuutil.a libqemustub.a
 qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) libqemuutil.a libqemustub.a
-qemu-io$(EXESUF): qemu-io.o qemu-io-cmds.o cmd.o $(block-obj-y) libqemuutil.a 
libqemustub.a
+qemu-io$(EXESUF): qemu-io.o qemu-io-cmds.o $(block-obj-y) libqemuutil.a 
libqemustub.a
 
 qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o
 
diff --git a/cmd.c b/cmd.c
deleted file mode 100644
index 26d38a8..000
--- a/cmd.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (c) 2003-2005 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see http://www.gnu.org/licenses/.
- */
-
-#include stdio.h
-#include stdlib.h
-#include string.h
-#include ctype.h
-#include errno.h
-#include sys/time.h
-#include getopt.h
-
-#include cmd.h
-#include block/aio.h
-#include qemu/main-loop.h
-
-#define _(x)   x   /* not gettext support yet */
-
-/* from libxcmd/command.c */
-
-#define EXABYTES(x)((long long)(x)  60)
-#define PETABYTES(x)   ((long long)(x)  50)
-#define TERABYTES(x)   ((long long)(x)  40)
-#define GIGABYTES(x)   ((long long)(x)  30)
-#define MEGABYTES(x)   ((long long)(x)  20)
-#define KILOBYTES(x)   ((long long)(x)  10)
-
-#define TO_EXABYTES(x) ((x) / EXABYTES(1))
-#define TO_PETABYTES(x)((x) / PETABYTES(1))
-#define TO_TERABYTES(x)((x) / TERABYTES(1))
-#define TO_GIGABYTES(x)((x) / GIGABYTES(1))
-#define TO_MEGABYTES(x)((x) / MEGABYTES(1))
-#define TO_KILOBYTES(x)((x) / KILOBYTES(1))
-
-void
-cvtstr(
-   double  value,
-   char*str,
-   size_t  size)
-{
-   char*trim;
-   const char  *suffix;
-
-   if (value = EXABYTES(1)) {
-   suffix =  EiB;
-   snprintf(str, size - 4, %.3f, TO_EXABYTES(value));
-   } else if (value = PETABYTES(1)) {
-   suffix =  PiB;
-   snprintf(str, size - 4, %.3f, TO_PETABYTES(value));
-   } else if (value = TERABYTES(1)) {
-   suffix =  TiB;
-   snprintf(str, size - 4, %.3f, TO_TERABYTES(value));
-   } else if (value = GIGABYTES(1)) {
-   suffix =  GiB;
-   snprintf(str, size - 4, %.3f, TO_GIGABYTES(value));
-   } else if (value = MEGABYTES(1)) {
-   suffix =  MiB;
-   snprintf(str, size - 4, %.3f, TO_MEGABYTES(value));
-   } else if (value = KILOBYTES(1)) {
-   suffix =  KiB;
-   snprintf(str, size - 4, %.3f, TO_KILOBYTES(value));
-   } else {
-   suffix =  bytes;
-   snprintf(str, size - 6, %f, value);
-   }
-
-   trim = strstr(str, .000);
-   if (trim) {
-   strcpy(trim, suffix);
-   } else {
-   strcat(str, suffix);
-   }
-}
-
-struct timeval
-tsub(struct timeval t1, struct timeval t2)
-{
-   t1.tv_usec -= t2.tv_usec;
-   if (t1.tv_usec  0) {
-   t1.tv_usec += 100;
-   t1.tv_sec--;
-   }
-   t1.tv_sec -= t2.tv_sec;
-   return t1;
-}
-
-double
-tdiv(double value, struct timeval tv)
-{
-   return value / ((double)tv.tv_sec + ((double)tv.tv_usec / 100.0));
-}
-
-#define HOURS(sec) ((sec) / (60 * 60))
-#define MINUTES(sec)   (((sec) % (60 * 60)) / 60)
-#define SECONDS(sec)   ((sec) % 60)
-
-void
-timestr(
-   struct timeval  *tv,
-   char*ts,
-   size_t  size,
-   int format)
-{
-   double  usec = (double)tv-tv_usec / 100.0;
-
-   if (format  TERSE_FIXED_TIME) {
-   if (!HOURS(tv-tv_sec)) {
-   snprintf(ts, size, %u:%02u.%02u,
-   (unsigned int) MINUTES(tv-tv_sec),
-   (unsigned int) SECONDS(tv-tv_sec),
-   (unsigned int) (usec * 100));
-   return;
-   }
-   format |= VERBOSE_FIXED_TIME;   /* fallback if hours 

[Qemu-devel] [PATCH v2 07/16] qemu-io: Factor out qemuio_command

2013-06-05 Thread Kevin Wolf
It's duplicated code. Move it to qemu-io-cmds.c because it's not
dependent on any static data of the qemu-io tool.

Signed-off-by: Kevin Wolf kw...@redhat.com
Reviewed-by: Eric Blake ebl...@redhat.com
---
 cmd.c  | 43 +--
 cmd.h  |  3 ++-
 qemu-io-cmds.c | 24 
 3 files changed, 31 insertions(+), 39 deletions(-)

diff --git a/cmd.c b/cmd.c
index d501aab..7ae978f 100644
--- a/cmd.c
+++ b/cmd.c
@@ -138,28 +138,11 @@ static char *get_prompt(void);
 
 void command_loop(void)
 {
-int c, i, done = 0, fetchable = 0, prompted = 0;
+int i, done = 0, fetchable = 0, prompted = 0;
 char *input;
-char **v;
-const cmdinfo_t *ct;
 
 for (i = 0; !done  i  ncmdline; i++) {
-input = strdup(cmdline[i]);
-if (!input) {
-fprintf(stderr, _(cannot strdup command '%s': %s\n),
-cmdline[i], strerror(errno));
-exit(1);
-}
-v = breakline(input, c);
-if (c) {
-ct = find_command(v[0]);
-if (ct) {
-done = command(ct, c, v);
-} else {
-fprintf(stderr, _(command \%s\ not found\n), v[0]);
-}
-   }
-doneline(input, v);
+done = qemuio_command(cmdline[i]);
 }
 if (cmdline) {
 g_free(cmdline);
@@ -179,20 +162,13 @@ void command_loop(void)
 if (!fetchable) {
 continue;
 }
+
 input = fetchline();
 if (input == NULL) {
 break;
 }
-v = breakline(input, c);
-if (c) {
-ct = find_command(v[0]);
-if (ct) {
-done = command(ct, c, v);
-} else {
-fprintf(stderr, _(command \%s\ not found\n), v[0]);
-}
-}
-doneline(input, v);
+done = qemuio_command(input);
+free(input);
 
 prompted = 0;
 fetchable = 0;
@@ -328,15 +304,6 @@ char **breakline(char *input, int *count)
 return rval;
 }
 
-void
-doneline(
-   char*input,
-   char**vec)
-{
-   free(input);
-   free(vec);
-}
-
 #define EXABYTES(x)((long long)(x)  60)
 #define PETABYTES(x)   ((long long)(x)  50)
 #define TERABYTES(x)   ((long long)(x)  40)
diff --git a/cmd.h b/cmd.h
index ccf6336..d676408 100644
--- a/cmd.h
+++ b/cmd.h
@@ -59,7 +59,6 @@ int command(const cmdinfo_t *ci, int argc, char **argv);
 
 /* from input.h */
 char **breakline(char *input, int *count);
-void doneline(char *input, char **vec);
 char *fetchline(void);
 
 void cvtstr(double value, char *str, size_t sz);
@@ -77,4 +76,6 @@ void timestr(struct timeval *tv, char *str, size_t sz, int 
flags);
 
 extern char *progname;
 
+bool qemuio_command(const char *cmd);
+
 #endif /* __COMMAND_H__ */
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index 0a3817a..8b12446 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -1807,6 +1807,30 @@ static int init_check_command(BlockDriverState *bs, 
const cmdinfo_t *ct)
 return 1;
 }
 
+bool qemuio_command(const char *cmd)
+{
+char *input;
+const cmdinfo_t *ct;
+char **v;
+int c;
+bool done = false;
+
+input = g_strdup(cmd);
+v = breakline(input, c);
+if (c) {
+ct = find_command(v[0]);
+if (ct) {
+done = command(ct, c, v);
+} else {
+fprintf(stderr, command \%s\ not found\n, v[0]);
+}
+}
+g_free(input);
+g_free(v);
+
+return done;
+}
+
 static void __attribute((constructor)) init_qemuio_commands(void)
 {
 /* initialize commands */
-- 
1.8.1.4




[Qemu-devel] [PATCH v2 09/16] qemu-io: Move 'quit' function

2013-06-05 Thread Kevin Wolf
This one only makes sense in the context of the qemu-io tool, so move it
to qemu-io.c. Adapt coding style and register it like other commands.

Signed-off-by: Kevin Wolf kw...@redhat.com
Reviewed-by: Eric Blake ebl...@redhat.com
---
 cmd.c | 29 -
 cmd.h |  2 --
 qemu-io.c | 17 -
 3 files changed, 16 insertions(+), 32 deletions(-)

diff --git a/cmd.c b/cmd.c
index 2941ad3..8496e74 100644
--- a/cmd.c
+++ b/cmd.c
@@ -410,32 +410,3 @@ timestr(
snprintf(ts, size, 0.%04u sec, (unsigned int) (usec * 1));
}
 }
-
-
-/* from libxcmd/quit.c */
-
-static cmdinfo_t quit_cmd;
-
-/* ARGSUSED */
-static int
-quit_f(
-BlockDriverState *bs,
-   int argc,
-   char**argv)
-{
-   return 1;
-}
-
-void
-quit_init(void)
-{
-   quit_cmd.name = _(quit);
-   quit_cmd.altname = _(q);
-   quit_cmd.cfunc = quit_f;
-   quit_cmd.argmin = -1;
-   quit_cmd.argmax = -1;
-   quit_cmd.flags = CMD_FLAG_GLOBAL;
-   quit_cmd.oneline = _(exit the program);
-
-   add_command(quit_cmd);
-}
diff --git a/cmd.h b/cmd.h
index 89e7c6e..5b6f61b 100644
--- a/cmd.h
+++ b/cmd.h
@@ -42,8 +42,6 @@ typedef struct cmdinfo {
 extern cmdinfo_t   *cmdtab;
 extern int ncmds;
 
-void quit_init(void);
-
 typedef int (*checkfunc_t)(BlockDriverState *bs, const cmdinfo_t *ci);
 
 void add_command(const cmdinfo_t *ci);
diff --git a/qemu-io.c b/qemu-io.c
index 14eef2c..8f6c57e 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -137,6 +137,21 @@ static int open_f(BlockDriverState *bs, int argc, char 
**argv)
 return openfile(argv[optind], flags, growable);
 }
 
+static int quit_f(BlockDriverState *bs, int argc, char **argv)
+{
+return 1;
+}
+
+static const cmdinfo_t quit_cmd = {
+.name   = quit,
+.altname= q,
+.cfunc  = quit_f,
+.argmin = -1,
+.argmax = -1,
+.flags  = CMD_FLAG_GLOBAL,
+.oneline= exit the program,
+};
+
 static void usage(const char *name)
 {
 printf(
@@ -247,7 +262,7 @@ int main(int argc, char **argv)
 bdrv_init();
 
 /* initialize commands */
-quit_init();
+add_command(quit_cmd);
 add_command(open_cmd);
 add_command(close_cmd);
 
-- 
1.8.1.4




[Qemu-devel] [PATCH v2 14/16] qemu-io: Interface cleanup

2013-06-05 Thread Kevin Wolf
Signed-off-by: Kevin Wolf kw...@redhat.com
---
 cmd.h | 48 
 include/qemu-io.h | 46 ++
 qemu-io-cmds.c| 14 +++---
 qemu-io.c |  7 +++
 4 files changed, 56 insertions(+), 59 deletions(-)
 delete mode 100644 cmd.h
 create mode 100644 include/qemu-io.h

diff --git a/cmd.h b/cmd.h
deleted file mode 100644
index 9907795..000
--- a/cmd.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2000-2005 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see http://www.gnu.org/licenses/.
- */
-#ifndef __COMMAND_H__
-#define __COMMAND_H__
-
-#include qemu-common.h
-
-#define CMD_FLAG_GLOBAL((int)0x8000)   /* don't iterate args 
*/
-
-extern BlockDriverState *qemuio_bs;
-
-typedef int (*cfunc_t)(BlockDriverState *bs, int argc, char **argv);
-typedef void (*helpfunc_t)(void);
-
-typedef struct cmdinfo {
-   const char  *name;
-   const char  *altname;
-   cfunc_t cfunc;
-   int argmin;
-   int argmax;
-   int canpush;
-   int flags;
-   const char  *args;
-   const char  *oneline;
-   helpfunc_t  help;
-} cmdinfo_t;
-
-void qemuio_add_command(const cmdinfo_t *ci);
-
-int qemuio_command_usage(const cmdinfo_t *ci);
-
-bool qemuio_command(const char *cmd);
-
-#endif /* __COMMAND_H__ */
diff --git a/include/qemu-io.h b/include/qemu-io.h
new file mode 100644
index 000..a418b46
--- /dev/null
+++ b/include/qemu-io.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2000-2005 Silicon Graphics, Inc.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see http://www.gnu.org/licenses/.
+ */
+
+#ifndef QEMU_IO_H
+#define QEMU_IO_H
+
+#include qemu-common.h
+
+#define CMD_FLAG_GLOBAL ((int)0x8000) /* don't iterate args */
+
+typedef int (*cfunc_t)(BlockDriverState *bs, int argc, char **argv);
+typedef void (*helpfunc_t)(void);
+
+typedef struct cmdinfo {
+const char* name;
+const char* altname;
+cfunc_t cfunc;
+int argmin;
+int argmax;
+int canpush;
+int flags;
+const char  *args;
+const char  *oneline;
+helpfunc_t  help;
+} cmdinfo_t;
+
+bool qemuio_command(BlockDriverState *bs, const char *cmd);
+
+void qemuio_add_command(const cmdinfo_t *ci);
+int qemuio_command_usage(const cmdinfo_t *ci);
+
+#endif /* QEMU_IO_H */
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index 05ce342..ffbcf31 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -8,9 +8,8 @@
  * See the COPYING file in the top-level directory.
  */
 
-#include qemu-common.h
+#include qemu-io.h
 #include block/block_int.h
-#include cmd.h
 
 #define CMD_NOFILE_OK   0x01
 
@@ -50,11 +49,12 @@ static int init_check_command(BlockDriverState *bs, const 
cmdinfo_t *ct)
 return 1;
 }
 
-static int command(const cmdinfo_t *ct, int argc, char **argv)
+static int command(BlockDriverState *bs, const cmdinfo_t *ct, int argc,
+   char **argv)
 {
 char *cmd = argv[0];
 
-if (!init_check_command(qemuio_bs, ct)) {
+if (!init_check_command(bs, ct)) {
 return 0;
 }
 
@@ -75,7 +75,7 @@ static int command(const cmdinfo_t *ct, int argc, char **argv)
 return 0;
 }
 optind = 0;
-return ct-cfunc(qemuio_bs, argc, argv);
+return ct-cfunc(bs, argc, argv);
 }
 
 static const cmdinfo_t *find_command(const char *cmd)
@@ -2068,7 +2068,7 @@ static const cmdinfo_t help_cmd = {
 .oneline= help for one or all commands,
 };
 
-bool qemuio_command(const char *cmd)
+bool qemuio_command(BlockDriverState *bs, const char *cmd)
 {
 char *input;
 const cmdinfo_t *ct;
@@ -2081,7 +2081,7 @@ bool qemuio_command(const char *cmd)
 if (c) {
 ct = find_command(v[0]);
 if (ct) {
-done = command(ct, c, v);
+done = 

[Qemu-devel] [PATCH v2 08/16] qemu-io: Move 'help' function

2013-06-05 Thread Kevin Wolf
No reason to treat it different from other commands. Move it to
qemu-io-cmds.c, adapt the coding style and register it like any other
command.

Signed-off-by: Kevin Wolf kw...@redhat.com
Reviewed-by: Eric Blake ebl...@redhat.com
---
 cmd.c  | 79 --
 cmd.h  |  1 -
 qemu-io-cmds.c | 67 -
 3 files changed, 66 insertions(+), 81 deletions(-)

diff --git a/cmd.c b/cmd.c
index 7ae978f..2941ad3 100644
--- a/cmd.c
+++ b/cmd.c
@@ -439,82 +439,3 @@ quit_init(void)
 
add_command(quit_cmd);
 }
-
-/* from libxcmd/help.c */
-
-static cmdinfo_t help_cmd;
-static void help_onecmd(const char *cmd, const cmdinfo_t *ct);
-static void help_oneline(const char *cmd, const cmdinfo_t *ct);
-
-static void
-help_all(void)
-{
-   const cmdinfo_t *ct;
-
-   for (ct = cmdtab; ct  cmdtab[ncmds]; ct++)
-   help_oneline(ct-name, ct);
-   printf(_(\nUse 'help commandname' for extended help.\n));
-}
-
-static int
-help_f(
-BlockDriverState *bs,
-   int argc,
-   char**argv)
-{
-   const cmdinfo_t *ct;
-
-   if (argc == 1) {
-   help_all();
-   return 0;
-   }
-   ct = find_command(argv[1]);
-   if (ct == NULL) {
-   printf(_(command %s not found\n), argv[1]);
-   return 0;
-   }
-   help_onecmd(argv[1], ct);
-   return 0;
-}
-
-static void
-help_onecmd(
-   const char  *cmd,
-   const cmdinfo_t *ct)
-{
-   help_oneline(cmd, ct);
-   if (ct-help)
-   ct-help();
-}
-
-static void
-help_oneline(
-   const char  *cmd,
-   const cmdinfo_t *ct)
-{
-   if (cmd)
-   printf(%s , cmd);
-   else {
-   printf(%s , ct-name);
-   if (ct-altname)
-   printf((or %s) , ct-altname);
-   }
-   if (ct-args)
-   printf(%s , ct-args);
-   printf(-- %s\n, ct-oneline);
-}
-
-void
-help_init(void)
-{
-   help_cmd.name = _(help);
-   help_cmd.altname = _(?);
-   help_cmd.cfunc = help_f;
-   help_cmd.argmin = 0;
-   help_cmd.argmax = 1;
-   help_cmd.flags = CMD_FLAG_GLOBAL;
-   help_cmd.args = _([command]);
-   help_cmd.oneline = _(help for one or all commands);
-
-   add_command(help_cmd);
-}
diff --git a/cmd.h b/cmd.h
index d676408..89e7c6e 100644
--- a/cmd.h
+++ b/cmd.h
@@ -42,7 +42,6 @@ typedef struct cmdinfo {
 extern cmdinfo_t   *cmdtab;
 extern int ncmds;
 
-void help_init(void);
 void quit_init(void);
 
 typedef int (*checkfunc_t)(BlockDriverState *bs, const cmdinfo_t *ci);
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index 8b12446..fa8d9a0 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -1795,6 +1795,71 @@ static const cmdinfo_t abort_cmd = {
.oneline= simulate a program crash using abort(3),
 };
 
+static void help_oneline(const char *cmd, const cmdinfo_t *ct)
+{
+if (cmd) {
+printf(%s , cmd);
+} else {
+printf(%s , ct-name);
+if (ct-altname) {
+printf((or %s) , ct-altname);
+}
+}
+
+if (ct-args) {
+printf(%s , ct-args);
+}
+printf(-- %s\n, ct-oneline);
+}
+
+static void help_onecmd(const char *cmd, const cmdinfo_t *ct)
+{
+help_oneline(cmd, ct);
+if (ct-help) {
+ct-help();
+}
+}
+
+static void help_all(void)
+{
+const cmdinfo_t *ct;
+
+for (ct = cmdtab; ct  cmdtab[ncmds]; ct++) {
+help_oneline(ct-name, ct);
+}
+printf(\nUse 'help commandname' for extended help.\n);
+}
+
+static int help_f(BlockDriverState *bs, int argc, char **argv)
+{
+const cmdinfo_t *ct;
+
+if (argc == 1) {
+help_all();
+return 0;
+}
+
+ct = find_command(argv[1]);
+if (ct == NULL) {
+printf(command %s not found\n, argv[1]);
+return 0;
+}
+
+help_onecmd(argv[1], ct);
+return 0;
+}
+
+static const cmdinfo_t help_cmd = {
+.name   = help,
+.altname= ?,
+.cfunc  = help_f,
+.argmin = 0,
+.argmax = 1,
+.flags  = CMD_FLAG_GLOBAL,
+.args   = [command],
+.oneline= help for one or all commands,
+};
+
 static int init_check_command(BlockDriverState *bs, const cmdinfo_t *ct)
 {
 if (ct-flags  CMD_FLAG_GLOBAL) {
@@ -1834,7 +1899,7 @@ bool qemuio_command(const char *cmd)
 static void __attribute((constructor)) init_qemuio_commands(void)
 {
 /* initialize commands */
-help_init();
+add_command(help_cmd);
 add_command(read_cmd);
 add_command(readv_cmd);
 add_command(write_cmd);
-- 
1.8.1.4




[Qemu-devel] [PATCH v2 16/16] Make qemu-io commands available in HMP

2013-06-05 Thread Kevin Wolf
It was decided to not make this command available in QMP in order to
make clear that this is not supposed to be a stable API and should be
used only for testing and debugging purposes.

Signed-off-by: Kevin Wolf kw...@redhat.com
---
 Makefile|  2 +-
 Makefile.objs   |  1 +
 hmp-commands.hx | 16 
 hmp.c   | 18 ++
 hmp.h   |  1 +
 5 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 87298e5..9a77ae0 100644
--- a/Makefile
+++ b/Makefile
@@ -186,7 +186,7 @@ qemu-img.o: qemu-img-cmds.h
 
 qemu-img$(EXESUF): qemu-img.o $(block-obj-y) libqemuutil.a libqemustub.a
 qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) libqemuutil.a libqemustub.a
-qemu-io$(EXESUF): qemu-io.o qemu-io-cmds.o $(block-obj-y) libqemuutil.a 
libqemustub.a
+qemu-io$(EXESUF): qemu-io.o $(block-obj-y) libqemuutil.a libqemustub.a
 
 qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o
 
diff --git a/Makefile.objs b/Makefile.objs
index 286ce06..5b288ba 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -13,6 +13,7 @@ block-obj-$(CONFIG_POSIX) += aio-posix.o
 block-obj-$(CONFIG_WIN32) += aio-win32.o
 block-obj-y += block/
 block-obj-y += qapi-types.o qapi-visit.o
+block-obj-y += qemu-io-cmds.o
 
 block-obj-y += qemu-coroutine.o qemu-coroutine-lock.o qemu-coroutine-io.o
 block-obj-y += qemu-coroutine-sleep.o
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 9cea415..a6167bd 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1551,6 +1551,22 @@ Removes the chardev @var{id}.
 ETEXI
 
 {
+.name   = qemu-io,
+.args_type  = device:B,command:s,
+.params = [device] \[command]\,
+.help   = run a qemu-io command on a block device,
+.mhandler.cmd = hmp_qemu_io,
+},
+
+STEXI
+@item qemu-io @var{device} @var{command}
+@findex qemu-io
+
+Executes a qemu-io command on the given block device.
+
+ETEXI
+
+{
 .name   = info,
 .args_type  = item:s?,
 .params = [subcommand],
diff --git a/hmp.c b/hmp.c
index 4fb76ec..64e0baa 100644
--- a/hmp.c
+++ b/hmp.c
@@ -22,6 +22,7 @@
 #include qemu/sockets.h
 #include monitor/monitor.h
 #include ui/console.h
+#include qemu-io.h
 
 static void hmp_handle_error(Monitor *mon, Error **errp)
 {
@@ -1425,3 +1426,20 @@ void hmp_chardev_remove(Monitor *mon, const QDict *qdict)
 qmp_chardev_remove(qdict_get_str(qdict, id), local_err);
 hmp_handle_error(mon, local_err);
 }
+
+void hmp_qemu_io(Monitor *mon, const QDict *qdict)
+{
+BlockDriverState *bs;
+const char* device = qdict_get_str(qdict, device);
+const char* command = qdict_get_str(qdict, command);
+Error *err = NULL;
+
+bs = bdrv_find(device);
+if (bs) {
+qemuio_command(bs, command);
+} else {
+error_set(err, QERR_DEVICE_NOT_FOUND, device);
+}
+
+hmp_handle_error(mon, err);
+}
diff --git a/hmp.h b/hmp.h
index 95fe76e..56d2e92 100644
--- a/hmp.h
+++ b/hmp.h
@@ -85,5 +85,6 @@ void hmp_nbd_server_add(Monitor *mon, const QDict *qdict);
 void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict);
 void hmp_chardev_add(Monitor *mon, const QDict *qdict);
 void hmp_chardev_remove(Monitor *mon, const QDict *qdict);
+void hmp_qemu_io(Monitor *mon, const QDict *qdict);
 
 #endif
-- 
1.8.1.4




Re: [Qemu-devel] [PATCH 00/39] Delay destruction of memory regions to instance_finalize

2013-06-05 Thread Andreas Färber
Am 05.06.2013 14:06, schrieb Michael S. Tsirkin:
 On Wed, Jun 05, 2013 at 01:32:17PM +0200, Andreas Färber wrote:
 Am 05.06.2013 13:10, schrieb Michael S. Tsirkin:
 On Wed, Jun 05, 2013 at 11:50:52AM +0200, Andreas Färber wrote:
 Am 04.06.2013 20:51, schrieb Paolo Bonzini:
 This series changes all PCI devices (the sole to support hotplug
 _and_ use MemoryRegions) to do memory_region_del_subregion at
 unrealize time, and memory_region_destroy at instance_finalize
 time.

 The general idea looks good.

 Could you please follow-up with a patch that switches from exit to
 unrealize?

 What do you guys think about changing the name to something
 else e.g. free or destroy?

 I'm not generally opposed to renaming things, but current unrealize is a
 pair with realize, and destroy or free doesn't really fit it's purpose -
 that's instance_finalize. Let's CC Anthony.
 
 So @instance_init - instance_alloc

No, allocation happens before instance_init, it only initializes fields
of the instance, so that name seems good to me.

My ISA realize patches (need to respin after Paolo enabled gus) worked
towards resolving the DeviceClass::init vs. instance_init ambiguity, so
once completed only instance_init and class_init would remain as
inits. PCI is a bit more involved, and would collide with this series;
Jesse's virtio-net config size issue is calling for converting
VirtioDevice, which might be quicker.

 instance_finalize - @instance_free?

/me misunderstandable, sorry. It doesn't free the instance either, and
Java uses finalize too and so does .NET iirc.

Anyway, my point was, when moving stuff out of exit, we should also
change the signature to the new one - DeviceState* and (unused) Error**.
Then we're getting closer to removing the old exit field, and at that
point renaming individual hooks - if desired - becomes a trivial patch.

Andreas

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



Re: [Qemu-devel] [PATCH 05/16] qemu-io: Don't use global bs in command implementations

2013-06-05 Thread Stefan Hajnoczi
On Tue, May 28, 2013 at 05:27:25PM +0200, Kevin Wolf wrote:
 Pass in the BlockDriverState to the command handlers instead of using
 the global variable. This is an important step to make the commands
 usable outside of qemu-io.
 
 Signed-off-by: Kevin Wolf kw...@redhat.com
 ---
  cmd.c |   6 ++-
  cmd.h |   8 ++-
  qemu-io.c | 165 
 ++
  3 files changed, 100 insertions(+), 79 deletions(-)
 
 diff --git a/cmd.c b/cmd.c
 index 214c6f7..d501aab 100644
 --- a/cmd.c
 +++ b/cmd.c
 @@ -57,7 +57,7 @@ check_command(
   const cmdinfo_t *ci)
  {
   if (check_func)
 - return check_func(ci);
 + return check_func(qemuio_bs, ci);
   return 1;
  }
  
 @@ -103,7 +103,7 @@ command(
   return 0;
   }
   optind = 0;
 - return ct-cfunc(argc, argv);
 + return ct-cfunc(qemuio_bs, argc, argv);
  }
  
  const cmdinfo_t *
 @@ -452,6 +452,7 @@ static cmdinfo_t quit_cmd;
  /* ARGSUSED */
  static int
  quit_f(
 +BlockDriverState *bs,
   int argc,

tabs vs spaces.  I try to keep the existing style unless I decide to
reformat the entire section of code.

Not trying to start a flamewar but this file appears to use tabs and IMO
you should stick to that instead of mixing spaces :-).

   char**argv)
  {
 @@ -490,6 +491,7 @@ help_all(void)
  
  static int
  help_f(
 +BlockDriverState *bs,
   int argc,
   char**argv)
  {
 diff --git a/cmd.h b/cmd.h
 index 4dcfe88..ccf6336 100644
 --- a/cmd.h
 +++ b/cmd.h
 @@ -17,9 +17,13 @@
  #ifndef __COMMAND_H__
  #define __COMMAND_H__
  
 +#include qemu-common.h
 +
  #define CMD_FLAG_GLOBAL  ((int)0x8000)   /* don't iterate args 
 */
  
 -typedef int (*cfunc_t)(int argc, char **argv);
 +extern BlockDriverState *qemuio_bs;
 +
 +typedef int (*cfunc_t)(BlockDriverState *bs, int argc, char **argv);
  typedef void (*helpfunc_t)(void);
  
  typedef struct cmdinfo {
 @@ -41,7 +45,7 @@ extern int  ncmds;
  void help_init(void);
  void quit_init(void);
  
 -typedef int (*checkfunc_t)(const cmdinfo_t *ci);
 +typedef int (*checkfunc_t)(BlockDriverState *bs, const cmdinfo_t *ci);
  
  void add_command(const cmdinfo_t *ci);
  void add_user_command(char *optarg);

cmd.h does not know about the block layer.  I would use void *opaque
instead of BlockDriverState *bs.  That way the file stays generic and
can be used in other command-line tools.



Re: [Qemu-devel] [PATCH qom-cpu v3 4/9] cpu: Turn cpu_paging_enabled() into a CPUState hook

2013-06-05 Thread Andreas Färber
Am 31.05.2013 15:33, schrieb Luiz Capitulino:
 On Thu, 30 May 2013 17:07:56 +0200
 Andreas Färber afaer...@suse.de wrote:
 
 Signed-off-by: Andreas Färber afaer...@suse.de
 
 Nitpick alarm on.

Very welcome :)

 ---
  include/qom/cpu.h | 10 ++
  include/sysemu/memory_mapping.h   |  1 -
  memory_mapping-stub.c |  6 --
  memory_mapping.c  |  2 +-
  qom/cpu.c | 13 +
  target-i386/arch_memory_mapping.c |  6 +-
  target-i386/cpu.c | 11 +--
  7 files changed, 34 insertions(+), 15 deletions(-)

 diff --git a/include/qom/cpu.h b/include/qom/cpu.h
 index 7cd9442..cf5fec2 100644
 --- a/include/qom/cpu.h
 +++ b/include/qom/cpu.h
 @@ -48,6 +48,7 @@ typedef struct CPUState CPUState;
   * @reset: Callback to reset the #CPUState to its initial state.
   * @do_interrupt: Callback for interrupt handling.
   * @get_arch_id: Callback for getting architecture-dependent CPU ID.
 + * @get_paging_enabled: Callback for inquiring whether paging is enabled.
   * @vmsd: State description for migration.
   *
   * Represents a CPU family or model.
 @@ -62,6 +63,7 @@ typedef struct CPUClass {
  void (*reset)(CPUState *cpu);
  void (*do_interrupt)(CPUState *cpu);
  int64_t (*get_arch_id)(CPUState *cpu);
 +bool (*get_paging_enabled)(CPUState *cpu);
 
 Argument could be const?

I haven't seen any other such example in QOM, but don't see why not,
changed [1].

[...]
 diff --git a/memory_mapping-stub.c b/memory_mapping-stub.c
 index 24d5d67..6c0dfeb 100644
 --- a/memory_mapping-stub.c
 +++ b/memory_mapping-stub.c
 @@ -25,9 +25,3 @@ int cpu_get_memory_mapping(MemoryMappingList *list,
  {
  return -1;
  }
 -
 -bool cpu_paging_enabled(CPUArchState *env)
 -{
 -return true;
 -}
 -
[...]
 diff --git a/qom/cpu.c b/qom/cpu.c
 index 04aefbb..ea7e676 100644
 --- a/qom/cpu.c
 +++ b/qom/cpu.c
 @@ -50,6 +50,18 @@ bool cpu_exists(int64_t id)
  return data.found;
  }
  
 +bool cpu_paging_enabled(CPUState *cpu)
 +{
 +CPUClass *cc = CPU_GET_CLASS(cpu);
 +
 +return cc-get_paging_enabled(cpu);
 +}
 +
 +static bool cpu_common_get_paging_enabled(CPUState *cpu)
 +{
 +return true;
 +}
 
 Not sure if this is important, but I wonder if we want to do this
 
 I mean, for all cases where you want to know if paging is enabled, what
 will happen if this default method says yes, it's enabled but it
 actually isn't?

As you can see, this is a direct conversation of today's stub into a
CPUClass callback. If we want to change the default, which I believe I
have advocated elsewhere, we should do so in a follow-up patch.

[...]
 diff --git a/target-i386/cpu.c b/target-i386/cpu.c
 index 1a501d9..7364e3b 100644
 --- a/target-i386/cpu.c
 +++ b/target-i386/cpu.c
[...]
 @@ -2519,6 +2526,8 @@ static void x86_cpu_common_class_init(ObjectClass *oc, 
 void *data)
  cc-reset = x86_cpu_reset;
  
  cc-do_interrupt = x86_cpu_do_interrupt;
 +cc-get_arch_id = x86_cpu_get_arch_id;
 
 Unrelated change?
 
 +cc-get_paging_enabled = x86_cpu_get_paging_enabled;
  #ifndef CONFIG_USER_ONLY
  cc-write_elf64_note = x86_cpu_write_elf64_note;
  cc-write_elf64_qemunote = x86_cpu_write_elf64_qemunote;
 @@ -2526,8 +2535,6 @@ static void x86_cpu_common_class_init(ObjectClass *oc, 
 void *data)
  cc-write_elf32_qemunote = x86_cpu_write_elf32_qemunote;
  #endif
  cpu_class_set_vmsd(cc, vmstate_x86_cpu);
 -
 -cc-get_arch_id = x86_cpu_get_arch_id;

As maintainer of target-i386/cpu.c I took the liberty of grouping the
get_* callbacks together - there is no reason to separate this one out,
and one of the following patches adds a get_memory_mapping field that
needs to be assigned  inside !CONFIG_USER_ONLY, thus get_paging_enabled
before the #ifndef.
And I think moving one line in its own patch would be overkill, even by
my standards. ;) But I should mention it in the commit message then.

Andreas

  }
  
  static const TypeInfo x86_cpu_type_info = {

[1] Diff:

diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index cf5fec2..1f70240 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -63,7 +63,7 @@ typedef struct CPUClass {
 void (*reset)(CPUState *cpu);
 void (*do_interrupt)(CPUState *cpu);
 int64_t (*get_arch_id)(CPUState *cpu);
-bool (*get_paging_enabled)(CPUState *cpu);
+bool (*get_paging_enabled)(const CPUState *cpu);

 const struct VMStateDescription *vmsd;
 int (*write_elf64_note)(WriteCoreDumpFunction f, CPUState *cpu,
@@ -145,7 +145,7 @@ struct CPUState {
  *
  * Returns: %true if paging is enabled, %false otherwise.
  */
-bool cpu_paging_enabled(CPUState *cpu);
+bool cpu_paging_enabled(const CPUState *cpu);

 /**
  * cpu_write_elf64_note:
diff --git a/qom/cpu.c b/qom/cpu.c
index ea7e676..9f6da0f 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -50,14 +50,14 @@ bool cpu_exists(int64_t id)
 return data.found;
 }

-bool cpu_paging_enabled(CPUState *cpu)
+bool 

Re: [Qemu-devel] [PATCH 07/16] qemu-io: Factor out qemuio_command

2013-06-05 Thread Stefan Hajnoczi
On Tue, May 28, 2013 at 05:27:27PM +0200, Kevin Wolf wrote:
 diff --git a/cmd.h b/cmd.h
 index ccf6336..d676408 100644
 --- a/cmd.h
 +++ b/cmd.h
 @@ -59,7 +59,6 @@ int command(const cmdinfo_t *ci, int argc, char **argv);
  
  /* from input.h */
  char **breakline(char *input, int *count);
 -void doneline(char *input, char **vec);
  char *fetchline(void);
  
  void cvtstr(double value, char *str, size_t sz);
 @@ -77,4 +76,6 @@ void timestr(struct timeval *tv, char *str, size_t sz, int 
 flags);
  
  extern char *progname;
  
 +bool qemuio_command(const char *cmd);

If we keep cmd.h generic then qemuio_command() should go into another
header file.



Re: [Qemu-devel] [PATCH 00/39] Delay destruction of memory regions to instance_finalize

2013-06-05 Thread Michael S. Tsirkin
On Wed, Jun 05, 2013 at 02:23:03PM +0200, Andreas Färber wrote:
 Am 05.06.2013 14:06, schrieb Michael S. Tsirkin:
  On Wed, Jun 05, 2013 at 01:32:17PM +0200, Andreas Färber wrote:
  Am 05.06.2013 13:10, schrieb Michael S. Tsirkin:
  On Wed, Jun 05, 2013 at 11:50:52AM +0200, Andreas Färber wrote:
  Am 04.06.2013 20:51, schrieb Paolo Bonzini:
  This series changes all PCI devices (the sole to support hotplug
  _and_ use MemoryRegions) to do memory_region_del_subregion at
  unrealize time, and memory_region_destroy at instance_finalize
  time.
 
  The general idea looks good.
 
  Could you please follow-up with a patch that switches from exit to
  unrealize?
 
  What do you guys think about changing the name to something
  else e.g. free or destroy?
 
  I'm not generally opposed to renaming things, but current unrealize is a
  pair with realize, and destroy or free doesn't really fit it's purpose -
  that's instance_finalize. Let's CC Anthony.
  
  So @instance_init - instance_alloc
 
 No, allocation happens before instance_init, it only initializes fields
 of the instance, so that name seems good to me.
 
 My ISA realize patches (need to respin after Paolo enabled gus) worked
 towards resolving the DeviceClass::init vs. instance_init ambiguity, so
 once completed only instance_init and class_init would remain as
 inits. PCI is a bit more involved, and would collide with this series;
 Jesse's virtio-net config size issue is calling for converting
 VirtioDevice, which might be quicker.
 
  instance_finalize - @instance_free?
 
 /me misunderstandable, sorry. It doesn't free the instance either, and
 Java uses finalize too and so does .NET iirc.

Well the do not have initialize though, so if someone comes from .NET
background that person will *still* be confused.

I think we should use names that pair well and are not ambiguous:
alloc/free  create/destroy   init/cleanup  (some people do init/uninit)
get/put ...

These are all standard C things with no ambiguity.




 Anyway, my point was, when moving stuff out of exit, we should also
 change the signature to the new one - DeviceState* and (unused) Error**.
 Then we're getting closer to removing the old exit field, and at that
 point renaming individual hooks - if desired - becomes a trivial patch.
 
 Andreas

Why is renaming new hooks related to getting rid of old ones?

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



Re: [Qemu-devel] [PATCH 08/16] qemu-io: Move 'help' function

2013-06-05 Thread Stefan Hajnoczi
On Tue, May 28, 2013 at 05:27:28PM +0200, Kevin Wolf wrote:
 No reason to treat it different from other commands. Move it to
 qemu-io-cmds.c, adapt the coding style and register it like any other
 command.
 
 Signed-off-by: Kevin Wolf kw...@redhat.com
 ---
  cmd.c  | 79 
 --
  cmd.h  |  1 -
  qemu-io-cmds.c | 67 -
  3 files changed, 66 insertions(+), 81 deletions(-)
 
 diff --git a/cmd.c b/cmd.c
 index 7ae978f..2941ad3 100644
 --- a/cmd.c
 +++ b/cmd.c

'help' is a generic command, it's not specific to qemu-io.  IMO cmd.c is
the right place for it since other command-line tools might also need
'help'.



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

2013-06-05 Thread Eric Blake
On 06/04/2013 09:58 PM, Wanlong Gao wrote:
 Add monitor command mem-nodes to show the huge mapped
 memory nodes locations.

Missing a QMP counterpart.  Libvirt would probably like to use this
command, and providing it HMP-only is not friendly.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH 05/16] qemu-io: Don't use global bs in command implementations

2013-06-05 Thread Kevin Wolf
Am 05.06.2013 um 14:28 hat Stefan Hajnoczi geschrieben:
 On Tue, May 28, 2013 at 05:27:25PM +0200, Kevin Wolf wrote:
  Pass in the BlockDriverState to the command handlers instead of using
  the global variable. This is an important step to make the commands
  usable outside of qemu-io.
  
  Signed-off-by: Kevin Wolf kw...@redhat.com
  ---
   cmd.c |   6 ++-
   cmd.h |   8 ++-
   qemu-io.c | 165 
  ++
   3 files changed, 100 insertions(+), 79 deletions(-)
  
  diff --git a/cmd.c b/cmd.c
  index 214c6f7..d501aab 100644
  --- a/cmd.c
  +++ b/cmd.c
  @@ -57,7 +57,7 @@ check_command(
  const cmdinfo_t *ci)
   {
  if (check_func)
  -   return check_func(ci);
  +   return check_func(qemuio_bs, ci);
  return 1;
   }
   
  @@ -103,7 +103,7 @@ command(
  return 0;
  }
  optind = 0;
  -   return ct-cfunc(argc, argv);
  +   return ct-cfunc(qemuio_bs, argc, argv);
   }
   
   const cmdinfo_t *
  @@ -452,6 +452,7 @@ static cmdinfo_t quit_cmd;
   /* ARGSUSED */
   static int
   quit_f(
  +BlockDriverState *bs,
  int argc,
 
 tabs vs spaces.  I try to keep the existing style unless I decide to
 reformat the entire section of code.
 
 Not trying to start a flamewar but this file appears to use tabs and IMO
 you should stick to that instead of mixing spaces :-).

Ah yes, didn't notice that.

Doesn't really matter though, at the end of the series cmd.c is gone.

  --- a/cmd.h
  +++ b/cmd.h
  @@ -17,9 +17,13 @@
   #ifndef __COMMAND_H__
   #define __COMMAND_H__
   
  +#include qemu-common.h
  +
   #define CMD_FLAG_GLOBAL((int)0x8000)   /* don't iterate args 
  */
   
  -typedef int (*cfunc_t)(int argc, char **argv);
  +extern BlockDriverState *qemuio_bs;
  +
  +typedef int (*cfunc_t)(BlockDriverState *bs, int argc, char **argv);
   typedef void (*helpfunc_t)(void);
   
   typedef struct cmdinfo {
  @@ -41,7 +45,7 @@ extern intncmds;
   void help_init(void);
   void quit_init(void);
   
  -typedef int (*checkfunc_t)(const cmdinfo_t *ci);
  +typedef int (*checkfunc_t)(BlockDriverState *bs, const cmdinfo_t *ci);
   
   void add_command(const cmdinfo_t *ci);
   void add_user_command(char *optarg);
 
 cmd.h does not know about the block layer.  I would use void *opaque
 instead of BlockDriverState *bs.  That way the file stays generic and
 can be used in other command-line tools.

Do you plan to use this in different context? Because this series is
exactly the opposite of keeping it generic. It moves everything directly
into qemu-io.

Kevin



Re: [Qemu-devel] [PATCH 11/16] qemu-io: Move functions for registering and running commands

2013-06-05 Thread Stefan Hajnoczi
On Tue, May 28, 2013 at 05:27:31PM +0200, Kevin Wolf wrote:
 Signed-off-by: Kevin Wolf kw...@redhat.com
 ---
  cmd.c  | 113 -
  cmd.h  |  11 +---
  qemu-io-cmds.c | 192 
 ++---
  qemu-io.c  |  10 +--
  4 files changed, 148 insertions(+), 178 deletions(-)

I haven't figured this out yet.  These patches move a bunch of generic
code and make it qemu-io-specific.  That seems the wrong direction to
go.



Re: [Qemu-devel] [Qemu-stable] [PATCH stable-1.1] qga: set umask 0077 when daemonizing (CVE-2013-2007)

2013-06-05 Thread Anthony Liguori
Michael Tokarev m...@tls.msk.ru writes:

 04.06.2013 18:23, Anthony Liguori wrote:
 Andreas Färber afaer...@suse.de writes:
 []
 Do we have an active maintainer for 1.1 or 1.3? Unfortunately qemu.git
 MAINTAINERS has not been updated with stable branches and maintainers
 for some time. If not, I'd be willing to step up for security fixes at
 least.

 I tried maintaining 1.1 (and I continue maintaining it in debian, but there
 i'm not really interested in unrelated things), but after multiple promises
 to get the tree published @qemu.org I gave up.

After a lot of thought, I don't want to do releases from previous stable
trees.

However, if someone wants to maintain a tree, I'm willing to accept pull
requests for it.  In fact, I'd like to phase out the separate stable
trees on qemu.org entirely and just move to a pull request based model.

Regards,

Anthony Liguori


 /mjt

 Can you setup a tree and do a pull request, also with a patch to set
 yourself up as maintainer?
 
 Thanks!
 
 Regards,
 
 Anthony Liguori
 
 
 

 Regards,
 Andreas

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




Re: [Qemu-devel] [PATCH 00/39] Delay destruction of memory regions to instance_finalize

2013-06-05 Thread Andreas Färber
Am 05.06.2013 14:36, schrieb Michael S. Tsirkin:
 Anyway, my point was, when moving stuff out of exit, we should also
 change the signature to the new one - DeviceState* and (unused) Error**.
 Then we're getting closer to removing the old exit field, and at that
 point renaming individual hooks - if desired - becomes a trivial patch.
 
 Why is renaming new hooks related to getting rid of old ones?

* less ambiguity and more names to choose from
* introducing new callbacks as done here for instance_finalize requires
care for variable names (PCIDevice *dev vs. DeviceState *dev is the
classic) whereas renaming a hook once used is a trivial one-line change
* renaming hooks now adds to the already existing confusion of a
half-done conversion

Andreas

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



Re: [Qemu-devel] [PATCH 1/2] tcg-arm: Implement tcg_register_jit

2013-06-05 Thread Richard Henderson
On 06/04/2013 06:56 PM, li guang wrote:
  +typedef struct {
  +uint32_t len __attribute__((aligned((sizeof(void *);
  +uint32_t cie_offset;
  +tcg_target_long func_start __attribute__((packed));
  +tcg_target_long func_len __attribute__((packed));
 suspicious usage of packed attribute here,
 since tcg_targe_long is either 32 or 64 bits,
 not a struct or union.
 
 Thanks!
 

Your question is worded poorly -- what has struct/union got to do with it?  One
can adjust the alignment of any type.  Perhaps you don't know what it is that
__attribute__((packed)) actually does?

While it's true that for ARM all four of these data members are 32-bit, and
thus none of the attributes are required, it's not actually wrong.  Given that
this sort of boiler-plate tends to get copied from target to target, and since
the attributes *are* required for 64-bit hosts, I prefer to keep all such
structures defined similarly.


r~



Re: [Qemu-devel] [PATCH 00/39] Delay destruction of memory regions to instance_finalize

2013-06-05 Thread Anthony Liguori
Michael S. Tsirkin m...@redhat.com writes:

 On Wed, Jun 05, 2013 at 11:50:52AM +0200, Andreas Färber wrote:
 Am 04.06.2013 20:51, schrieb Paolo Bonzini:
  This series changes all PCI devices (the sole to support hotplug
  _and_ use MemoryRegions) to do memory_region_del_subregion at
  unrealize time, and memory_region_destroy at instance_finalize
  time.
 
 The general idea looks good.
 
 Could you please follow-up with a patch that switches from exit to
 unrealize?

 What do you guys think about changing the name to something
 else e.g. free or destroy?

exit/unrealize != free/destroy.

You don't actually free anything.  See 00/39 in this series for a
precise description.

 unrealize is not a word in english:
 http://dictionary.cambridge.org/spellcheck/american-english/?q=unrealize

English is a fluid language.  I wouldn't worry too much about that.

Regards,

Anthony Liguori

 I can do it easily if people agree.

 use BUS(), PCI_DEVICE() etc. to hide this.
 
 Andreas
 
 -- 
 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
 GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] qemu openpty

2013-06-05 Thread Brad Smith

On 05/06/13 6:28 AM, Michael Tokarev wrote:

Hello.

One of old issues with compatibility between different
*Nix systems was the way how pty pairs were allocated.

And qemu have a twist in #includes, depending on which
platform it is run, and quite some compat cruft in
qemu-char.c about this issue.

Here it is, from qemu-char.c:

#ifdef __sun__
/* Once Solaris has openpty(), this is going to be removed. */
static int openpty(int *amaster, int *aslave, char *name,
struct termios *termp, struct winsize *winp)
{...}

static void cfmakeraw (struct termios *termios_p)
{...}
#endif

and later on, openpty() is used in the code.  Note that
both functions are marked as static - static to the
source file, qemu-char.c.

Now, we have ui/gtk.c, which calls openpty() and cfmakeraw()
too, but this time, there's no compat alternative implementation
provided.

Does this mean we don't need the old compat implementation
anymore?  Does gtk ui work (or at least builds) on solaris?

If gtk builds fine on solaris, it should be safe to remove
these static functions from qemu-char.c.

If not, we should obviously re-use these for ui/gtk.c --
for which I'd create a new file, say, qemu-openpty.c,
with all the system-dependent stuff inside, and create
a wrapper function, qemu_openpty(), to do the work,
and, ofcourse, remove pty.h and other fancy stuff
(like stropts.h for solaris) from qemu-common.h (!!!)
where it finally ended up.

Thanks,

/mjt


Solaris does not have openpty() / cfmakeraw() functions so
the Gtk+ front-end is broken there as well.


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.




Re: [Qemu-devel] qemu openpty

2013-06-05 Thread Brad Smith

On 05/06/13 6:28 AM, Michael Tokarev wrote:

Hello.

One of old issues with compatibility between different
*Nix systems was the way how pty pairs were allocated.

And qemu have a twist in #includes, depending on which
platform it is run, and quite some compat cruft in
qemu-char.c about this issue.

Here it is, from qemu-char.c:

#ifdef __sun__
/* Once Solaris has openpty(), this is going to be removed. */
static int openpty(int *amaster, int *aslave, char *name,
struct termios *termp, struct winsize *winp)
{...}

static void cfmakeraw (struct termios *termios_p)
{...}
#endif

and later on, openpty() is used in the code.  Note that
both functions are marked as static - static to the
source file, qemu-char.c.

Now, we have ui/gtk.c, which calls openpty() and cfmakeraw()
too, but this time, there's no compat alternative implementation
provided.

Does this mean we don't need the old compat implementation
anymore?  Does gtk ui work (or at least builds) on solaris?

If gtk builds fine on solaris, it should be safe to remove
these static functions from qemu-char.c.

If not, we should obviously re-use these for ui/gtk.c --
for which I'd create a new file, say, qemu-openpty.c,
with all the system-dependent stuff inside, and create
a wrapper function, qemu_openpty(), to do the work,
and, ofcourse, remove pty.h and other fancy stuff
(like stropts.h for solaris) from qemu-common.h (!!!)
where it finally ended up.

Thanks,

/mjt


Solaris does not have openpty() / cfmakeraw() functions so
the Gtk+ front-end is broken there as well.


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.




[Qemu-devel] [PATCH] cputlb: fix debug logs

2013-06-05 Thread Hervé Poussineau
'pd' variable has been removed in 06ef3525e1f271b6a842781a05eace5cf63b95c2.

Signed-off-by: Hervé Poussineau hpous...@reactos.org
---
 cputlb.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cputlb.c b/cputlb.c
index 8c8..1230e9e 100644
--- a/cputlb.c
+++ b/cputlb.c
@@ -262,8 +262,8 @@ void tlb_set_page(CPUArchState *env, target_ulong vaddr,
 
 #if defined(DEBUG_TLB)
 printf(tlb_set_page: vaddr= TARGET_FMT_lx  paddr=0x TARGET_FMT_plx
-prot=%x idx=%d pd=0x%08lx\n,
-   vaddr, paddr, prot, mmu_idx, pd);
+prot=%x idx=%d\n,
+   vaddr, paddr, prot, mmu_idx);
 #endif
 
 address = vaddr;
-- 
1.7.10.4




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

2013-06-05 Thread Anthony Liguori
Wanlong Gao gaowanl...@cn.fujitsu.com writes:

 Add monitor command mem-nodes to show the huge mapped
 memory nodes locations.

 (qemu) info mem-nodes
 /proc/14132/fd/13: 2ac0-2aaaeac0: node0
 /proc/14132/fd/13: 2aaaeac0-2aab2ac0: node1
 /proc/14132/fd/14: 2aab2ac0-2aab2b00: node0
 /proc/14132/fd/14: 2aab2b00-2aab2b40: node1

This creates an ABI that we don't currently support.  Memory hotplug or
a variety of things can break this mapping and then we'd have to provide
an interface to describe that the mapping was broken.

Also, it only works with hugetlbfs which is probbably not widely used
given the existance of THP.

I had hoped that we would get proper userspace interfaces for describing
memory groups but that appears to have stalled out.

Does anyone know if this is still on the table?

If we can't get a proper kernel interface, then perhaps we need to add
full libnuma support but that would really be unfortunate...

Regards,

Anthony Liguori


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

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

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




Re: [Qemu-devel] [PATCH 1/2] tcg-arm: Implement tcg_register_jit

2013-06-05 Thread Andreas Färber
Am 05.06.2013 14:49, schrieb Richard Henderson:
 On 06/04/2013 06:56 PM, li guang wrote:
 +typedef struct {
 +uint32_t len __attribute__((aligned((sizeof(void *);
 +uint32_t cie_offset;
 +tcg_target_long func_start __attribute__((packed));
 +tcg_target_long func_len __attribute__((packed));
 suspicious usage of packed attribute here,
 since tcg_targe_long is either 32 or 64 bits,
 not a struct or union.

 Thanks!

 
 Your question is worded poorly -- what has struct/union got to do with it?  
 One
 can adjust the alignment of any type.  Perhaps you don't know what it is that
 __attribute__((packed)) actually does?

To me the English word packed refers to a struct containing no
alignment padding, i.e. sizeof(the struct) = sum(sizeof(each field)).
The use of __attribute__((packed)) on an individual field while quite
possibly valid is unusual and I believe we have a QEMU_PACKED macro.

So why can't you apply QEMU_PACKED to the whole struct? Because of the
contradicting void* alignment attribute of the first field?

Cheers,
Andreas

 While it's true that for ARM all four of these data members are 32-bit, and
 thus none of the attributes are required, it's not actually wrong.  Given that
 this sort of boiler-plate tends to get copied from target to target, and since
 the attributes *are* required for 64-bit hosts, I prefer to keep all such
 structures defined similarly.
 
 
 r~

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



Re: [Qemu-devel] [PATCH 00/16] Make qemu-io commands available in the monitor

2013-06-05 Thread Stefan Hajnoczi
On Tue, May 28, 2013 at 05:27:20PM +0200, Kevin Wolf wrote:
 This is a prerequisite for some kind of tests. It involves reorganising the
 qemu-io code so that the command part can be separated and doesn't pollute the
 global namespace any more, so we can link it with qemu.
 
 Kevin Wolf (16):
   qemu-io: Remove unused args_command
   cutils: Support 'P' and 'E' suffixes in strtosz()
   qemu-io: Make cvtnum() a wrapper around strtosz_suffix()
   qemu-io: Handle cvtnum() errors in 'alloc'
   qemu-io: Don't use global bs in command implementations
   qemu-io: Split off commands to qemu-io-cmds.c
   qemu-io: Factor out qemuio_command
   qemu-io: Move 'help' function
   qemu-io: Move 'quit' function
   qemu-io: Move qemu_strsep() to cutils.c
   qemu-io: Move functions for registering and running commands
   qemu-io: Move command_loop() and friends
   qemu-io: Move remaining helpers from cmd.c
   qemu-io: Interface cleanup
   qemu-io: Use the qemu version for -V
   Make qemu-io commands available in the monitor
 
  Makefile   |2 +-
  Makefile.objs  |1 +
  blockdev.c |   15 +
  cmd.c  |  612 -
  cmd.h  |   79 --
  hmp-commands.hx|   16 +
  hmp.c  |   10 +
  hmp.h  |1 +
  include/qemu-common.h  |3 +
  include/qemu-io.h  |   46 +
  monitor.c  |8 +-
  qapi-schema.json   |   16 +
  qemu-img.c |   10 +-
  qemu-io-cmds.c | 2118 
 
  qemu-io.c  | 1988 -
  qmp-commands.hx|   28 +
  tests/qemu-iotests/049.out |8 +-
  util/cutils.c  |   25 +
  18 files changed, 2466 insertions(+), 2520 deletions(-)
  delete mode 100644 cmd.c
  delete mode 100644 cmd.h
  create mode 100644 include/qemu-io.h
  create mode 100644 qemu-io-cmds.c

Mostly good but I think cmd.c should be preserved.  It's a generic
command-line dispatcher and shouldn't be squashed into qemu-io-cmds.c.



[Qemu-devel] [PATCH v2 05/16] qemu-io: Don't use global bs in command implementations

2013-06-05 Thread Kevin Wolf
Pass in the BlockDriverState to the command handlers instead of using
the global variable. This is an important step to make the commands
usable outside of qemu-io.

Signed-off-by: Kevin Wolf kw...@redhat.com
Reviewed-by: Eric Blake ebl...@redhat.com
---
 cmd.c |   6 ++-
 cmd.h |   8 ++-
 qemu-io.c | 167 ++
 3 files changed, 101 insertions(+), 80 deletions(-)

diff --git a/cmd.c b/cmd.c
index 214c6f7..d501aab 100644
--- a/cmd.c
+++ b/cmd.c
@@ -57,7 +57,7 @@ check_command(
const cmdinfo_t *ci)
 {
if (check_func)
-   return check_func(ci);
+   return check_func(qemuio_bs, ci);
return 1;
 }
 
@@ -103,7 +103,7 @@ command(
return 0;
}
optind = 0;
-   return ct-cfunc(argc, argv);
+   return ct-cfunc(qemuio_bs, argc, argv);
 }
 
 const cmdinfo_t *
@@ -452,6 +452,7 @@ static cmdinfo_t quit_cmd;
 /* ARGSUSED */
 static int
 quit_f(
+BlockDriverState *bs,
int argc,
char**argv)
 {
@@ -490,6 +491,7 @@ help_all(void)
 
 static int
 help_f(
+BlockDriverState *bs,
int argc,
char**argv)
 {
diff --git a/cmd.h b/cmd.h
index 4dcfe88..ccf6336 100644
--- a/cmd.h
+++ b/cmd.h
@@ -17,9 +17,13 @@
 #ifndef __COMMAND_H__
 #define __COMMAND_H__
 
+#include qemu-common.h
+
 #define CMD_FLAG_GLOBAL((int)0x8000)   /* don't iterate args 
*/
 
-typedef int (*cfunc_t)(int argc, char **argv);
+extern BlockDriverState *qemuio_bs;
+
+typedef int (*cfunc_t)(BlockDriverState *bs, int argc, char **argv);
 typedef void (*helpfunc_t)(void);
 
 typedef struct cmdinfo {
@@ -41,7 +45,7 @@ extern intncmds;
 void help_init(void);
 void quit_init(void);
 
-typedef int (*checkfunc_t)(const cmdinfo_t *ci);
+typedef int (*checkfunc_t)(BlockDriverState *bs, const cmdinfo_t *ci);
 
 void add_command(const cmdinfo_t *ci);
 void add_user_command(char *optarg);
diff --git a/qemu-io.c b/qemu-io.c
index b4f56fc..39d7063 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -25,8 +25,8 @@
 #define CMD_NOFILE_OK   0x01
 
 char *progname;
-static BlockDriverState *bs;
 
+BlockDriverState *qemuio_bs;
 static int misalign;
 
 static int64_t cvtnum(const char *s)
@@ -63,7 +63,7 @@ static int parse_pattern(const char *arg)
  */
 
 #define MISALIGN_OFFSET 16
-static void *qemu_io_alloc(size_t len, int pattern)
+static void *qemu_io_alloc(BlockDriverState *bs, size_t len, int pattern)
 {
 void *buf;
 
@@ -136,7 +136,8 @@ static void print_report(const char *op, struct timeval *t, 
int64_t offset,
  * vector matching it.
  */
 static void *
-create_iovec(QEMUIOVector *qiov, char **argv, int nr_iov, int pattern)
+create_iovec(BlockDriverState *bs, QEMUIOVector *qiov, char **argv, int nr_iov,
+ int pattern)
 {
 size_t *sizes = g_new0(size_t, nr_iov);
 size_t count = 0;
@@ -172,7 +173,7 @@ create_iovec(QEMUIOVector *qiov, char **argv, int nr_iov, 
int pattern)
 
 qemu_iovec_init(qiov, nr_iov);
 
-buf = p = qemu_io_alloc(count, pattern);
+buf = p = qemu_io_alloc(bs, count, pattern);
 
 for (i = 0; i  nr_iov; i++) {
 qemu_iovec_add(qiov, p, sizes[i]);
@@ -184,7 +185,8 @@ fail:
 return buf;
 }
 
-static int do_read(char *buf, int64_t offset, int count, int *total)
+static int do_read(BlockDriverState *bs, char *buf, int64_t offset, int count,
+   int *total)
 {
 int ret;
 
@@ -196,7 +198,8 @@ static int do_read(char *buf, int64_t offset, int count, 
int *total)
 return 1;
 }
 
-static int do_write(char *buf, int64_t offset, int count, int *total)
+static int do_write(BlockDriverState *bs, char *buf, int64_t offset, int count,
+int *total)
 {
 int ret;
 
@@ -208,7 +211,8 @@ static int do_write(char *buf, int64_t offset, int count, 
int *total)
 return 1;
 }
 
-static int do_pread(char *buf, int64_t offset, int count, int *total)
+static int do_pread(BlockDriverState *bs, char *buf, int64_t offset, int count,
+int *total)
 {
 *total = bdrv_pread(bs, offset, (uint8_t *)buf, count);
 if (*total  0) {
@@ -217,7 +221,8 @@ static int do_pread(char *buf, int64_t offset, int count, 
int *total)
 return 1;
 }
 
-static int do_pwrite(char *buf, int64_t offset, int count, int *total)
+static int do_pwrite(BlockDriverState *bs, char *buf, int64_t offset, int 
count,
+ int *total)
 {
 *total = bdrv_pwrite(bs, offset, (uint8_t *)buf, count);
 if (*total  0) {
@@ -227,6 +232,7 @@ static int do_pwrite(char *buf, int64_t offset, int count, 
int *total)
 }
 
 typedef struct {
+BlockDriverState *bs;
 int64_t offset;
 int count;
 int *total;
@@ -238,7 +244,7 @@ static void coroutine_fn co_write_zeroes_entry(void *opaque)
 {
 CoWriteZeroes *data = opaque;
 
-data-ret = bdrv_co_write_zeroes(bs, data-offset / BDRV_SECTOR_SIZE,
+data-ret = bdrv_co_write_zeroes(data-bs, 

[Qemu-devel] [PATCH v2 12/16] qemu-io: Move command_loop() and friends

2013-06-05 Thread Kevin Wolf
Signed-off-by: Kevin Wolf kw...@redhat.com
---
 cmd.c | 139 --
 cmd.h |   9 
 qemu-io.c | 139 ++
 3 files changed, 139 insertions(+), 148 deletions(-)

diff --git a/cmd.c b/cmd.c
index 6616d61..26d38a8 100644
--- a/cmd.c
+++ b/cmd.c
@@ -31,145 +31,6 @@
 
 /* from libxcmd/command.c */
 
-static int ncmdline;
-static char**cmdline;
-
-
-void add_user_command(char *optarg)
-{
-cmdline = g_realloc(cmdline, ++ncmdline * sizeof(char *));
-cmdline[ncmdline-1] = optarg;
-}
-
-static void prep_fetchline(void *opaque)
-{
-int *fetchable = opaque;
-
-qemu_set_fd_handler(STDIN_FILENO, NULL, NULL, NULL);
-*fetchable= 1;
-}
-
-static char *get_prompt(void);
-
-void command_loop(void)
-{
-int i, done = 0, fetchable = 0, prompted = 0;
-char *input;
-
-for (i = 0; !done  i  ncmdline; i++) {
-done = qemuio_command(cmdline[i]);
-}
-if (cmdline) {
-g_free(cmdline);
-return;
-}
-
-while (!done) {
-if (!prompted) {
-printf(%s, get_prompt());
-fflush(stdout);
-qemu_set_fd_handler(STDIN_FILENO, prep_fetchline, NULL, 
fetchable);
-prompted = 1;
-}
-
-main_loop_wait(false);
-
-if (!fetchable) {
-continue;
-}
-
-input = fetchline();
-if (input == NULL) {
-break;
-}
-done = qemuio_command(input);
-free(input);
-
-prompted = 0;
-fetchable = 0;
-}
-qemu_set_fd_handler(STDIN_FILENO, NULL, NULL, NULL);
-}
-
-/* from libxcmd/input.c */
-
-#if defined(ENABLE_READLINE)
-# include readline/history.h
-# include readline/readline.h
-#elif defined(ENABLE_EDITLINE)
-# include histedit.h
-#endif
-
-static char *
-get_prompt(void)
-{
-   static char prompt[FILENAME_MAX + 2 /* */ + 1 /*\0*/ ];
-
-   if (!prompt[0])
-   snprintf(prompt, sizeof(prompt), %s , progname);
-   return prompt;
-}
-
-#if defined(ENABLE_READLINE)
-char *
-fetchline(void)
-{
-   char*line;
-
-   line = readline(get_prompt());
-   if (line  *line)
-   add_history(line);
-   return line;
-}
-#elif defined(ENABLE_EDITLINE)
-static char *el_get_prompt(EditLine *e) { return get_prompt(); }
-char *
-fetchline(void)
-{
-   static EditLine *el;
-   static History  *hist;
-   HistEvent   hevent;
-   char*line;
-   int count;
-
-   if (!el) {
-   hist = history_init();
-   history(hist, hevent, H_SETSIZE, 100);
-   el = el_init(progname, stdin, stdout, stderr);
-   el_source(el, NULL);
-   el_set(el, EL_SIGNAL, 1);
-   el_set(el, EL_PROMPT, el_get_prompt);
-   el_set(el, EL_HIST, history, (const char *)hist);
-   }
-   line = strdup(el_gets(el, count));
-   if (line) {
-   if (count  0)
-   line[count-1] = '\0';
-   if (*line)
-   history(hist, hevent, H_ENTER, line);
-   }
-   return line;
-}
-#else
-# define MAXREADLINESZ 1024
-char *
-fetchline(void)
-{
-   char*p, *line = malloc(MAXREADLINESZ);
-
-   if (!line)
-   return NULL;
-   if (!fgets(line, MAXREADLINESZ, stdin)) {
-   free(line);
-   return NULL;
-   }
-   p = line + strlen(line);
-   if (p != line  p[-1] == '\n')
-   p[-1] = '\0';
-   return line;
-}
-#endif
-
 #define EXABYTES(x)((long long)(x)  60)
 #define PETABYTES(x)   ((long long)(x)  50)
 #define TERABYTES(x)   ((long long)(x)  40)
diff --git a/cmd.h b/cmd.h
index 0d01a33..da0c7cf 100644
--- a/cmd.h
+++ b/cmd.h
@@ -39,18 +39,11 @@ typedef struct cmdinfo {
helpfunc_t  help;
 } cmdinfo_t;
 
-typedef int (*checkfunc_t)(BlockDriverState *bs, const cmdinfo_t *ci);
-
 void qemuio_add_command(const cmdinfo_t *ci);
-void add_user_command(char *optarg);
-void add_check_command(checkfunc_t cf);
 
-void command_loop(void);
 int qemuio_command_usage(const cmdinfo_t *ci);
 
 /* from input.h */
-char *fetchline(void);
-
 void cvtstr(double value, char *str, size_t sz);
 
 struct timeval tsub(struct timeval t1, struct timeval t2);
@@ -64,8 +57,6 @@ enum {
 
 void timestr(struct timeval *tv, char *str, size_t sz, int flags);
 
-extern char *progname;
-
 bool qemuio_command(const char *cmd);
 
 #endif /* __COMMAND_H__ */
diff --git a/qemu-io.c b/qemu-io.c
index 3bf5aec..eec8cbc 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -29,6 +29,10 @@ char *progname;
 BlockDriverState *qemuio_bs;
 extern int qemuio_misalign;
 
+/* qemu-io commands passed using -c */
+static int ncmdline;
+static char **cmdline;
+
 static int close_f(BlockDriverState *bs, int argc, char **argv)
 {
 bdrv_delete(bs);
@@ -174,6 +178,141 @@ static 

Re: [Qemu-devel] qemu openpty

2013-06-05 Thread Anthony Liguori
Michael Tokarev m...@tls.msk.ru writes:

 Hello.

 One of old issues with compatibility between different
 *Nix systems was the way how pty pairs were allocated.

 And qemu have a twist in #includes, depending on which
 platform it is run, and quite some compat cruft in
 qemu-char.c about this issue.

 Here it is, from qemu-char.c:

 #ifdef __sun__
 /* Once Solaris has openpty(), this is going to be removed. */
 static int openpty(int *amaster, int *aslave, char *name,
struct termios *termp, struct winsize *winp)
 {...}

 static void cfmakeraw (struct termios *termios_p)
 {...}
 #endif

This code is gross.

 and later on, openpty() is used in the code.  Note that
 both functions are marked as static - static to the
 source file, qemu-char.c.

 Now, we have ui/gtk.c, which calls openpty() and cfmakeraw()
 too, but this time, there's no compat alternative implementation
 provided.

 Does this mean we don't need the old compat implementation
 anymore?  Does gtk ui work (or at least builds) on solaris?

I didn't carry this code over to the GTK UI because 1) I have no way to
test it 2) it adds a lot of complexity for something that may be used by
noone.

 If gtk builds fine on solaris, it should be safe to remove
 these static functions from qemu-char.c.

I think we're quickly getting to a point where we should simply state
that in order for any OS to be supported by QEMU, there must be a
buildbot.  Otherwise the testing burden is too high.

I'll send a top-level note with such a proposal.

Regards,

Anthony Liguori

 If not, we should obviously re-use these for ui/gtk.c --
 for which I'd create a new file, say, qemu-openpty.c,
 with all the system-dependent stuff inside, and create
 a wrapper function, qemu_openpty(), to do the work,
 and, ofcourse, remove pty.h and other fancy stuff
 (like stropts.h for solaris) from qemu-common.h (!!!)
 where it finally ended up.

 Thanks,

 /mjt




Re: [Qemu-devel] [PATCH 1/2] tcg-arm: Implement tcg_register_jit

2013-06-05 Thread Richard Henderson
On 06/05/2013 06:02 AM, Andreas Färber wrote:
 So why can't you apply QEMU_PACKED to the whole struct? Because of the
 contradicting void* alignment attribute of the first field?

Actually, that might work.  I'll give it a shot on x86_64 and change all
of the uses if it does work.


r~



[Qemu-devel] [PULL 0/2] tcg: Remove redundant tcg_target_init checks

2013-06-05 Thread Richard Henderson
Reviewing the tcg/aarch64 patch set, and comparing that to
existing hosts made me remember that I've wanted to do this
for quite some time.

Now with two reviews, please pull.


r~


The following changes since commit 8819c10b5d55d537d59a0ffd5d623f348fc36c47:

  Merge remote-tracking branch 'sstabellini/xen_fixes_20130603' into staging 
(2013-06-04 14:58:58 -0500)

are available in the git repository at:


  git://github.com/rth7680/qemu.git tcg-for-anthony

for you to fetch changes up to 56bbc2f967ce185fa1c5c39e1aeb5b68b26242e9:

  tcg: Remove redundant tcg_target_init checks (2013-06-05 05:54:40 -0700)


Richard Henderson (2):
  tcg: Use QEMU_BUILD_BUG_ON for CPU_TLB_ENTRY_BITS
  tcg: Remove redundant tcg_target_init checks

 include/exec/cpu-defs.h | 2 +-
 tcg/arm/tcg-target.c| 6 --
 tcg/i386/tcg-target.c   | 6 --
 tcg/s390/tcg-target.c   | 7 ---
 4 files changed, 1 insertion(+), 20 deletions(-)

-- 
1.8.1.4




[Qemu-devel] [PULL 2/2] tcg: Remove redundant tcg_target_init checks

2013-06-05 Thread Richard Henderson
We've got a compile-time check for the condition in exec/cpu-defs.h.

Reviewed-by: Andreas Färber afaer...@suse.de
Reviewed-by: liguang lig.f...@cn.fujitsu.com
Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/arm/tcg-target.c  | 6 --
 tcg/i386/tcg-target.c | 6 --
 tcg/s390/tcg-target.c | 7 ---
 3 files changed, 19 deletions(-)

diff --git a/tcg/arm/tcg-target.c b/tcg/arm/tcg-target.c
index 3d43412..6be736b 100644
--- a/tcg/arm/tcg-target.c
+++ b/tcg/arm/tcg-target.c
@@ -2053,12 +2053,6 @@ static const TCGTargetOpDef arm_op_defs[] = {
 
 static void tcg_target_init(TCGContext *s)
 {
-#if !defined(CONFIG_USER_ONLY)
-/* fail safe */
-if ((1  CPU_TLB_ENTRY_BITS) != sizeof(CPUTLBEntry))
-tcg_abort();
-#endif
-
 tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0x);
 tcg_regset_set32(tcg_target_call_clobber_regs, 0,
  (1  TCG_REG_R0) |
diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c
index 9eec06c..9e95477 100644
--- a/tcg/i386/tcg-target.c
+++ b/tcg/i386/tcg-target.c
@@ -2283,12 +2283,6 @@ static void tcg_target_init(TCGContext *s)
 }
 #endif
 
-#if !defined(CONFIG_USER_ONLY)
-/* fail safe */
-if ((1  CPU_TLB_ENTRY_BITS) != sizeof(CPUTLBEntry))
-tcg_abort();
-#endif
-
 if (TCG_TARGET_REG_BITS == 64) {
 tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0x);
 tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I64], 0, 0x);
diff --git a/tcg/s390/tcg-target.c b/tcg/s390/tcg-target.c
index 7d6f777..f229f1c 100644
--- a/tcg/s390/tcg-target.c
+++ b/tcg/s390/tcg-target.c
@@ -2324,13 +2324,6 @@ static void query_facilities(void)
 
 static void tcg_target_init(TCGContext *s)
 {
-#if !defined(CONFIG_USER_ONLY)
-/* fail safe */
-if ((1  CPU_TLB_ENTRY_BITS) != sizeof(CPUTLBEntry)) {
-tcg_abort();
-}
-#endif
-
 query_facilities();
 
 tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0x);
-- 
1.8.1.4




Re: [Qemu-devel] [PATCH qom-cpu v3 6/9] cpu: Turn cpu_get_memory_mapping() into a CPUState hook

2013-06-05 Thread Andreas Färber
Am 31.05.2013 15:48, schrieb Luiz Capitulino:
 On Thu, 30 May 2013 17:07:58 +0200
 Andreas Färber afaer...@suse.de wrote:
 
 Signed-off-by: Andreas Färber afaer...@suse.de
 ---
  include/qom/cpu.h | 11 +++
  include/sysemu/memory_mapping.h   |  2 --
  memory_mapping-stub.c |  6 --
  memory_mapping.c  |  2 +-
  qom/cpu.c | 14 ++
  target-i386/arch_memory_mapping.c |  7 +--
  target-i386/cpu-qom.h |  2 ++
  target-i386/cpu.c |  1 +
  8 files changed, 34 insertions(+), 11 deletions(-)

 diff --git a/include/qom/cpu.h b/include/qom/cpu.h
 index cf5fec2..93a4612 100644
 --- a/include/qom/cpu.h
 +++ b/include/qom/cpu.h
 @@ -23,6 +23,7 @@
  #include signal.h
  #include hw/qdev-core.h
  #include qemu/thread.h
 +#include qemu/typedefs.h
  
  typedef int (*WriteCoreDumpFunction)(void *buf, size_t size, void *opaque);
  
 @@ -49,6 +50,7 @@ typedef struct CPUState CPUState;
   * @do_interrupt: Callback for interrupt handling.
   * @get_arch_id: Callback for getting architecture-dependent CPU ID.
   * @get_paging_enabled: Callback for inquiring whether paging is enabled.
 + * @get_memory_mapping: Callback for obtaining the memory mappings.
   * @vmsd: State description for migration.
   *
   * Represents a CPU family or model.
 @@ -64,6 +66,7 @@ typedef struct CPUClass {
  void (*do_interrupt)(CPUState *cpu);
  int64_t (*get_arch_id)(CPUState *cpu);
  bool (*get_paging_enabled)(CPUState *cpu);
 +int (*get_memory_mapping)(CPUState *cpu, MemoryMappingList *list);
 
 Would be nice to take an Error argument and fill it properly when
 get_memory_mapping() is not implemented.

Done.

Andreas

diff --cc include/qom/cpu.h
index 1f70240,93a4612..000
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@@ -63,7 -65,8 +65,9 @@@ typedef struct CPUClass
  void (*reset)(CPUState *cpu);
  void (*do_interrupt)(CPUState *cpu);
  int64_t (*get_arch_id)(CPUState *cpu);
 -bool (*get_paging_enabled)(CPUState *cpu);
 -int (*get_memory_mapping)(CPUState *cpu, MemoryMappingList *list);
 +bool (*get_paging_enabled)(const CPUState *cpu);
++void (*get_memory_mapping)(CPUState *cpu, MemoryMappingList *list,
++   Error **errp);

  const struct VMStateDescription *vmsd;
  int (*write_elf64_note)(WriteCoreDumpFunction f, CPUState *cpu,
@@@ -145,9 -148,17 +149,19 @@@ struct CPUState
   *
   * Returns: %true if paging is enabled, %false otherwise.
   */
 -bool cpu_paging_enabled(CPUState *cpu);
 +bool cpu_paging_enabled(const CPUState *cpu);

  /**
+  * @cpu: The CPU whose memory mappings are to be obtained.
+  * @list: Where to write the memory mappings to.
++ * @errp: Pointer for reporting an #Error.
+  *
+  * Returns: 0 if successful.
+  */
 -int cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list);
++void cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list,
++Error **errp);
+
+ /**
   * cpu_write_elf64_note:
   * @f: pointer to a function that writes memory to a file
   * @cpu: The CPU whose memory is to be dumped
diff --git a/memory_mapping.c b/memory_mapping.c
index 481530a..9bd24ce 100644
--- a/memory_mapping.c
+++ b/memory_mapping.c
@@ -183,13 +183,14 @@ int
qemu_get_guest_memory_mapping(MemoryMappingList *list)
 CPUArchState *env, *first_paging_enabled_cpu;
 RAMBlock *block;
 ram_addr_t offset, length;
-int ret;

 first_paging_enabled_cpu = find_paging_enabled_cpu(first_cpu);
 if (first_paging_enabled_cpu) {
 for (env = first_paging_enabled_cpu; env != NULL; env =
env-next_cpu) {
-ret = cpu_get_memory_mapping(ENV_GET_CPU(env), list);
-if (ret  0) {
+Error *err = NULL;
+cpu_get_memory_mapping(ENV_GET_CPU(env), list, err);
+if (err) {
+error_free(err);
 return -1;
 }
 }
diff --git a/qom/cpu.c b/qom/cpu.c
index 97063e1..b25fbc9 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -62,17 +62,19 @@ static bool cpu_common_get_paging_enabled(const
CPUState *cpu)
 return true;
 }

-int cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list)
+void cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list,
+Error **errp)
 {
 CPUClass *cc = CPU_GET_CLASS(cpu);

-return cc-get_memory_mapping(cpu, list);
+return cc-get_memory_mapping(cpu, list, errp);
 }

-static int cpu_common_get_memory_mapping(CPUState *cpu,
- MemoryMappingList *list)
+static void cpu_common_get_memory_mapping(CPUState *cpu,
+  MemoryMappingList *list,
+  Error **errp)
 {
-return -1;
+error_setg(errp, Obtaining memory mappings is unsupported on this
CPU.);
 }

 /* CPU hot-plug notifiers */
diff --git 

Re: [Qemu-devel] [PATCH 1/2] tcg-arm: Implement tcg_register_jit

2013-06-05 Thread Peter Maydell
On 5 June 2013 14:04, Richard Henderson r...@twiddle.net wrote:
 On 06/05/2013 06:02 AM, Andreas Färber wrote:
 So why can't you apply QEMU_PACKED to the whole struct? Because of the
 contradicting void* alignment attribute of the first field?

 Actually, that might work.  I'll give it a shot on x86_64 and change all
 of the uses if it does work.

Bear in mind that making the entire structure 'packed' means
gcc treats it as being potentially completely unaligned
(ie attribute 'packed' means 'packed and not at all aligned',
not just 'packed'). This isn't a big deal except for structs
where we care about atomicity, though, which I don't think
is the case here.

-- PMM



Re: [Qemu-devel] [BACKPORT qemu-xen 0/3] fixes for 4.3

2013-06-05 Thread George Dunlap

On 05/06/13 13:07, Stefano Stabellini wrote:

Hi all,
this patch series backports few fixes from QEMU to qemu-xen 4.3.


The second patch avoid calling main_loop_wait with nonblocking set to 1,
so that the select timeout is always as high as possible on Xen.

The third patch fixes this PCI passthrough bug:
http://marc.info/?l=xen-develm=136242365010750


Re the release:

Acked-by: George Dunlap george.dun...@eu.citrix.com





  1   2   3   >