[Qemu-devel] [Bug 1089281] Re: kvm crash when writing on disk

2012-12-31 Thread xavy
Running it with ide solved the FC.
Thanks for the comments Stefan ;)

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1089281

Title:
  kvm crash when writing on disk

Status in QEMU:
  New

Bug description:
  When running the following command:

  /usr/bin/kvm -S -M pc-1.0 -cpu qemu32 -enable-kvm -m 1024 -smp
  1,sockets=1,cores=1,threads=1 -name winxp -uuid f86ef88f-b90e-699a-
  74b8-9675063fc26e -nodefconfig -nodefaults -chardev
  socket,id=charmonitor,path=/var/lib/libvirt/qemu/winxp.monitor,server,nowait
  -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-
  shutdown -device lsi,id=scsi0,bus=pci.0,addr=0x4 -drive
  file=/home/master/xpnew.iso,if=none,media=cdrom,id=drive-
  ide0-0-0,readonly=on,format=raw -device ide-
  drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1
  -drive file=/var/lib/zentyal/machines/winxp/winxp.img,if=none,id
  =drive-scsi0-0-0,format=qcow2 -device scsi-disk,bus=scsi0.0,scsi-
  id=0,drive=drive-scsi0-0-0,id=scsi0-0-0 -netdev tap,fd=18,id=hostnet0
  -device
  rtl8139,netdev=hostnet0,id=net0,mac=b3:b8:a9:49:a2:f8,bus=pci.0,addr=0x3
  -usb -device usb-mouse,id=input0 -vnc 0.0.0.0:0,password -k de -vga
  cirrus -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5

  
  running a windows installation (for instance, it has crashed with other OS), 
when the guest OS installer has reached 60% of the copying files process, the 
following errors can be found, and KVM gets Force Closed (i am recollecting 
errors from different times I have tried to references to memory positions may 
vary)

  syslog:

  Nov 26 19:46:59 mikeboxx kernel: [2254718.689953] kvm6983 general
  protection ip:7fc451d4be08 sp:7fc44991ab80 error:0 in
  libc-2.15.so[7fc451ccd000+1b5000]

  /var/log/libvirt/libvirtd.log:

  2012-11-21 10:01:26.464+: 16050: error : qemuMonitorIO:603 :
  internal error End of file from monitor

  /var/log/libvirt/qemu/winxp-ajur.log

  **enclosed as it has a long size due to the core dump

  
  The linux kernel running is this one:

  3.2.0-32-generic #51-Ubuntu SMP Wed Sep 26 21:33:09 UTC 2012 x86_64
  x86_64 x86_64 GNU/Linux

  Libvirtd versions are these:
  root@mikeboxx:/home/ebox-remote-support# dpkg -l | grep libvirt
  ii  libvirt-bin  0.9.8-2ubuntu17.4
  programs for the libvirt library
  ii  libvirt0 0.9.8-2ubuntu17.4
  library for interfacing with different virtualization systems

  and KVM - QEMU versions are these ones:
  root@mikeboxx:/home/ebox-remote-support# dpkg -l | grep qemu
  ii  qemu-common  1.0+noroms-0ubuntu14.3   
  qemu common functionality (bios, documentation, etc)
  ii  qemu-kvm 1.0+noroms-0ubuntu14.3   
  Full virtualization on i386 and amd64 hardware
  ii  qemu-utils   1.0+noroms-0ubuntu14.3   
  qemu utilities


  I have checked bug  #1022901 in
  https://bugs.launchpad.net/ubuntu/+source/qemu-kvm/+bug/1022901  due
  to the similarity of the error "internal error End of file from
  monitor", but the sintoms are not the same as long as the partition
  where the img file resides has plenty of space and so does the img
  itself:

  root@mikeboxx:/home/ebox-remote-support# df -h
  Filesystem  Size  Used Avail Use% Mounted on
  /dev/sda1   226G  3.4G  211G   2% /

  root@mikeboxx:/home/ebox-remote-support# qemu-img info 
/var/lib/zentyal/machines/winxp/winxp.img 
  image: /var/lib/zentyal/machines/winxp/winxp.img
  file format: qcow2
  virtual size: 11G (11559501824 bytes)
  disk size: 384M
  cluster_size: 65536

  
  Can you help us to solve this? Case you needed any information else, please 
do not hesitate to ask for it

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1089281/+subscriptions



[Qemu-devel] [PATCH] savevm.c: cleanup system includes

2012-12-31 Thread Michael Tokarev
savevm.c suffers from the same problem as some other files.
Some years ago savevm.c was created from vl.c, moving some
code from there into a separate file.  At that time, all
includes were just copied from vl.c to savevm.c, without
checking which ones are needed and which are not.

But actually most of that stuff is _not_ needed.  More, some
stuff is wrong, for example, *BSD #ifdef'ery around 
vs  - for one, it fails to build on Debian/kFreebsd.

Just remove all this.  Maybe there's a possibility to clean
it up further - like removing  (and maybe including
winsock.h for htons etc), and maybe it's possible to remove
some internal #includes too, but I didn't check this.

While at it, remove duplicate #include of qemu/timer.h.

Signed-off-by: Michael Tokarev 
---
 savevm.c |   40 +---
 1 file changed, 1 insertion(+), 39 deletions(-)

diff --git a/savevm.c b/savevm.c
index bcdb92e..529d60e 100644
--- a/savevm.c
+++ b/savevm.c
@@ -21,52 +21,15 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-/* Needed early for CONFIG_BSD etc. */
+
 #include "config-host.h"
 
 #ifndef _WIN32
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
 #include 
-#include 
-#include 
-#include 
-#ifdef CONFIG_BSD
-#include 
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || 
defined(__DragonFly__)
-#include 
-#else
-#include 
-#endif
-#ifdef __linux__
-#include 
-#include 
-#include 
-#endif
-#endif
 #endif
 
 #ifdef _WIN32
 #include 
-#include 
-#include 
-#include 
-#define getopt_long_only getopt_long
-#define memalign(align, size) malloc(size)
 #endif
 
 #include "qemu-common.h"
@@ -80,7 +43,6 @@
 #include "migration/migration.h"
 #include "qemu/sockets.h"
 #include "qemu/queue.h"
-#include "qemu/timer.h"
 #include "sysemu/cpus.h"
 #include "exec/memory.h"
 #include "qmp-commands.h"
-- 
1.7.10.4




[Qemu-devel] [PATCH RFC 2/3] xen_disk: fix memory leak

2012-12-31 Thread Roger Pau Monne
On ioreq_release the full ioreq was memset to 0, loosing all the data
and memory allocations inside the QEMUIOVector, which leads to a
memory leak. Create a new function to specifically reset ioreq.

Reported-by: Maik Wessler 
Signed-off-by: Roger Pau Monné 
Cc: xen-de...@lists.xen.org
Cc: Stefano Stabellini 
Cc: Anthony PERARD 
---
 hw/xen_disk.c |   28 ++--
 1 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/hw/xen_disk.c b/hw/xen_disk.c
index a159ee5..1eb485a 100644
--- a/hw/xen_disk.c
+++ b/hw/xen_disk.c
@@ -113,6 +113,31 @@ struct XenBlkDev {
 
 /* - */
 
+static void ioreq_reset(struct ioreq *ioreq)
+{
+memset(&ioreq->req, 0, sizeof(ioreq->req));
+ioreq->status = 0;
+ioreq->start = 0;
+ioreq->presync = 0;
+ioreq->postsync = 0;
+ioreq->mapped = 0;
+
+memset(ioreq->domids, 0, sizeof(ioreq->domids));
+memset(ioreq->refs, 0, sizeof(ioreq->refs));
+ioreq->prot = 0;
+memset(ioreq->page, 0, sizeof(ioreq->page));
+ioreq->pages = NULL;
+
+ioreq->aio_inflight = 0;
+ioreq->aio_errors = 0;
+
+ioreq->blkdev = NULL;
+memset(&ioreq->list, 0, sizeof(ioreq->list));
+memset(&ioreq->acct, 0, sizeof(ioreq->acct));
+
+qemu_iovec_reset(&ioreq->v);
+}
+
 static struct ioreq *ioreq_start(struct XenBlkDev *blkdev)
 {
 struct ioreq *ioreq = NULL;
@@ -130,7 +155,6 @@ static struct ioreq *ioreq_start(struct XenBlkDev *blkdev)
 /* get one from freelist */
 ioreq = QLIST_FIRST(&blkdev->freelist);
 QLIST_REMOVE(ioreq, list);
-qemu_iovec_reset(&ioreq->v);
 }
 QLIST_INSERT_HEAD(&blkdev->inflight, ioreq, list);
 blkdev->requests_inflight++;
@@ -154,7 +178,7 @@ static void ioreq_release(struct ioreq *ioreq, bool finish)
 struct XenBlkDev *blkdev = ioreq->blkdev;
 
 QLIST_REMOVE(ioreq, list);
-memset(ioreq, 0, sizeof(*ioreq));
+ioreq_reset(ioreq);
 ioreq->blkdev = blkdev;
 QLIST_INSERT_HEAD(&blkdev->freelist, ioreq, list);
 if (finish) {
-- 
1.7.7.5 (Apple Git-26)




[Qemu-devel] [PATCH RFC 0/3] xen pv disk persistent grants implementation

2012-12-31 Thread Roger Pau Monne
This series contains two bug fixes for xen_disk (patches 1 & 2) and 
the implementation of the persistent grants extensions (patch 3), that 
brings a considerable speed improvement.

Thanks for the reviews, Roger.



[Qemu-devel] [PATCH RFC 1/3] xen_disk: handle disk files on ramfs/tmpfs

2012-12-31 Thread Roger Pau Monne
Files that reside on ramfs or tmpfs cannot be opened with O_DIRECT,
if first call to bdrv_open fails with errno = EINVAL, try a second
call without BDRV_O_NOCACHE.

Signed-off-by: Roger Pau Monné 
Cc: xen-de...@lists.xen.org
Cc: Stefano Stabellini 
Cc: Anthony PERARD 
---
 hw/xen_disk.c |   16 +---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/hw/xen_disk.c b/hw/xen_disk.c
index e6bb2f2..a159ee5 100644
--- a/hw/xen_disk.c
+++ b/hw/xen_disk.c
@@ -562,7 +562,7 @@ static void blk_alloc(struct XenDevice *xendev)
 static int blk_init(struct XenDevice *xendev)
 {
 struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev);
-int index, qflags, info = 0;
+int index, qflags, info = 0, rc;
 
 /* read xenstore entries */
 if (blkdev->params == NULL) {
@@ -625,8 +625,18 @@ static int blk_init(struct XenDevice *xendev)
 xen_be_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n");
 blkdev->bs = bdrv_new(blkdev->dev);
 if (blkdev->bs) {
-if (bdrv_open(blkdev->bs, blkdev->filename, qflags,
-bdrv_find_whitelisted_format(blkdev->fileproto)) != 0) 
{
+rc = bdrv_open(blkdev->bs, blkdev->filename, qflags,
+bdrv_find_whitelisted_format(blkdev->fileproto));
+if (rc != 0 && errno == EINVAL) {
+/* Files on ramfs or tmpfs cannot be opened with O_DIRECT,
+ * remove the BDRV_O_NOCACHE flag, and try to open
+ * the file again.
+ */
+qflags &= ~BDRV_O_NOCACHE;
+rc = bdrv_open(blkdev->bs, blkdev->filename, qflags,
+bdrv_find_whitelisted_format(blkdev->fileproto));
+}
+if (rc != 0) {
 bdrv_delete(blkdev->bs);
 blkdev->bs = NULL;
 }
-- 
1.7.7.5 (Apple Git-26)




[Qemu-devel] [PATCH RFC 3/3] xen_disk: add persistent grant support to xen_disk backend

2012-12-31 Thread Roger Pau Monne
This protocol extension reuses the same set of grant pages for all
transactions between the front/back drivers, avoiding expensive tlb
flushes, grant table lock contention and switches between userspace
and kernel space. The full description of the protocol can be found in
the public blkif.h header.

Speed improvement with 15 guests performing I/O is ~450%.

Signed-off-by: Roger Pau Monné 
Cc: xen-de...@lists.xen.org
Cc: Stefano Stabellini 
Cc: Anthony PERARD 
---
Performance comparison with the previous implementation can be seen in
the followign graph:

http://xenbits.xen.org/people/royger/persistent_read_qemu.png
---
 hw/xen_disk.c |  155 ++--
 1 files changed, 138 insertions(+), 17 deletions(-)

diff --git a/hw/xen_disk.c b/hw/xen_disk.c
index 1eb485a..bafeceb 100644
--- a/hw/xen_disk.c
+++ b/hw/xen_disk.c
@@ -52,6 +52,11 @@ static int max_requests = 32;
 #define BLOCK_SIZE  512
 #define IOCB_COUNT  (BLKIF_MAX_SEGMENTS_PER_REQUEST + 2)
 
+struct persistent_gnt {
+void *page;
+struct XenBlkDev *blkdev;
+};
+
 struct ioreq {
 blkif_request_t req;
 int16_t status;
@@ -69,6 +74,7 @@ struct ioreq {
 int prot;
 void*page[BLKIF_MAX_SEGMENTS_PER_REQUEST];
 void*pages;
+int num_unmap;
 
 /* aio status */
 int aio_inflight;
@@ -105,6 +111,12 @@ struct XenBlkDev {
 int requests_inflight;
 int requests_finished;
 
+/* Persistent grants extension */
+gbooleanfeature_persistent;
+GTree   *persistent_gnts;
+unsigned intpersistent_gnt_c;
+unsigned intmax_grants;
+
 /* qemu block driver */
 DriveInfo   *dinfo;
 BlockDriverState*bs;
@@ -138,6 +150,29 @@ static void ioreq_reset(struct ioreq *ioreq)
 qemu_iovec_reset(&ioreq->v);
 }
 
+static gint int_cmp(gconstpointer a, gconstpointer b, gpointer user_data)
+{
+uint ua = GPOINTER_TO_UINT(a);
+uint ub = GPOINTER_TO_UINT(b);
+return (ua > ub) - (ua < ub);
+}
+
+static void destroy_grant(gpointer pgnt)
+{
+struct persistent_gnt *grant = pgnt;
+XenGnttab gnt = grant->blkdev->xendev.gnttabdev;
+
+if (xc_gnttab_munmap(gnt, grant->page, 1) != 0) {
+xen_be_printf(&grant->blkdev->xendev, 0,
+  "xc_gnttab_munmap failed: %s\n",
+  strerror(errno));
+}
+grant->blkdev->persistent_gnt_c--;
+xen_be_printf(&grant->blkdev->xendev, 3,
+  "unmapped grant %p\n", grant->page);
+g_free(grant);
+}
+
 static struct ioreq *ioreq_start(struct XenBlkDev *blkdev)
 {
 struct ioreq *ioreq = NULL;
@@ -266,21 +301,21 @@ static void ioreq_unmap(struct ioreq *ioreq)
 XenGnttab gnt = ioreq->blkdev->xendev.gnttabdev;
 int i;
 
-if (ioreq->v.niov == 0 || ioreq->mapped == 0) {
+if (ioreq->num_unmap == 0 || ioreq->mapped == 0) {
 return;
 }
 if (batch_maps) {
 if (!ioreq->pages) {
 return;
 }
-if (xc_gnttab_munmap(gnt, ioreq->pages, ioreq->v.niov) != 0) {
+if (xc_gnttab_munmap(gnt, ioreq->pages, ioreq->num_unmap) != 0) {
 xen_be_printf(&ioreq->blkdev->xendev, 0, "xc_gnttab_munmap failed: 
%s\n",
   strerror(errno));
 }
-ioreq->blkdev->cnt_map -= ioreq->v.niov;
+ioreq->blkdev->cnt_map -= ioreq->num_unmap;
 ioreq->pages = NULL;
 } else {
-for (i = 0; i < ioreq->v.niov; i++) {
+for (i = 0; i < ioreq->num_unmap; i++) {
 if (!ioreq->page[i]) {
 continue;
 }
@@ -298,41 +333,107 @@ static void ioreq_unmap(struct ioreq *ioreq)
 static int ioreq_map(struct ioreq *ioreq)
 {
 XenGnttab gnt = ioreq->blkdev->xendev.gnttabdev;
-int i;
+uint32_t domids[BLKIF_MAX_SEGMENTS_PER_REQUEST];
+uint32_t refs[BLKIF_MAX_SEGMENTS_PER_REQUEST];
+void *page[BLKIF_MAX_SEGMENTS_PER_REQUEST];
+int i, j, new_maps = 0;
+struct persistent_gnt *grant;
 
 if (ioreq->v.niov == 0 || ioreq->mapped == 1) {
 return 0;
 }
-if (batch_maps) {
+if (ioreq->blkdev->feature_persistent) {
+for (i = 0; i < ioreq->v.niov; i++) {
+grant = g_tree_lookup(ioreq->blkdev->persistent_gnts,
+GUINT_TO_POINTER(ioreq->refs[i]));
+
+if (grant != NULL) {
+page[i] = grant->page;
+xen_be_printf(&ioreq->blkdev->xendev, 3,
+  "using persistent-grant %" PRIu32 "\n",
+  ioreq->refs[i]);
+} else {
+/* Add the grant to the list of grants that
+ * should be mapped
+ */
+domids[new_maps] = ioreq->domids[i];
+refs[new_maps] = ioreq->refs[i];
+

Re: [Qemu-devel] setting migrate_downtime results in halted vm (qemu 1.3)

2012-12-31 Thread Stefan Priebe

When i try to cancel a running migration with qemu git i get a segfault.

BT:
(gdb) bt
#0  _wordcopy_bwd_aligned (dstp=140051233112024, srcp=140051233112016, 
len=529920) at wordcopy.c:298
#1  0x7f61dd7c86da in *__GI_memmove (dest=0x7f6037bf5010, 
src=, len=38118264) at memmove.c:99
#2  0x7f61e2e973c9 in buffered_flush (s=0x7f61e33a9e60) at 
migration.c:546
#3  0x7f61e2e9746c in buffered_close (opaque=0x7f61e33a9e60) at 
migration.c:598

#4  0x7f61e2f758ff in qemu_fclose (f=0x7f6044fc3200)
at 
/opt/debianpackages/pve-squeeze.sources/pve-qemu-kvm/qemu-kvm/savevm.c:543
#5  0x7f61e2e975b6 in migrate_fd_cleanup (s=0x7f61e33a9e60) at 
migration.c:277
#6  0x7f61e2f7406b in handle_user_command (mon=0x7fffce7e3a90, 
cmdline=)
at 
/opt/debianpackages/pve-squeeze.sources/pve-qemu-kvm/qemu-kvm/monitor.c:3945
#7  0x7f61e2f74279 in qmp_human_monitor_command 
(command_line=0x7f604c9361b0 "migrate_cancel", has_cpu_index=false,
cpu_index=140051576672336, errp=0x7fffce7e3f68) at 
/opt/debianpackages/pve-squeeze.sources/pve-qemu-kvm/qemu-kvm/monitor.c:664
#8  0x7f61e2ecec07 in qmp_marshal_input_human_monitor_command 
(mon=, qdict=, ret=0x7fffce7e3ff0)

at qmp-marshal.c:1505
#9  0x7f61e2f6f53f in qmp_call_cmd (params=, 
cmd=, mon=)
at 
/opt/debianpackages/pve-squeeze.sources/pve-qemu-kvm/qemu-kvm/monitor.c:4446

#10 handle_qmp_command (parser=, tokens=)
at 
/opt/debianpackages/pve-squeeze.sources/pve-qemu-kvm/qemu-kvm/monitor.c:4512
#11 0x7f61e2e9039c in json_message_process_token 
(lexer=0x7f61d0012470, token=0x7f60389d6c60, type=JSON_OPERATOR,

x=, y=) at json-streamer.c:87
#12 0x7f61e2e8ec60 in json_lexer_feed_char (lexer=0x7f61d0012470, 
ch=125 '}', flush=false) at json-lexer.c:303
#13 0x7f61e2e8ee19 in json_lexer_feed (lexer=0x7f61d0012470, 
buffer=0x7fffce7e41f0 "}\277\370M`\177", size=1)

at json-lexer.c:356
#14 0x7f61e2f6d65e in monitor_control_read (opaque=, 
buf=0x7f604000 " ", size=529920)
at 
/opt/debianpackages/pve-squeeze.sources/pve-qemu-kvm/qemu-kvm/monitor.c:4533
#15 0x7f61e2ebedab in tcp_chr_read (opaque=0x7f61e4e1e610) at 
qemu-char.c:2325
#16 0x7f61e2e8dac7 in qemu_iohandler_poll (readfds=0x7f61e37bc660, 
writefds=0x7f61e37bc6e0, xfds=,

ret=) at iohandler.c:124
#17 0x7f61e2e95f79 in main_loop_wait (nonblocking=) 
at main-loop.c:418

#18 0x7f61e2f0f56c in main_loop () at vl.c:1768
#19 main (argc=, argv=, envp=out>) at vl.c:4047


Stefan

Am 29.12.2012 16:25, schrieb Paolo Bonzini:

Il 29/12/2012 16:19, Stefan Priebe ha scritto:



I suppose it will be between 05e72dc5812a9f461fc2c606dff2572909eafc39
and aa723c23147e93fef8475bd80fd29e633378c34d.

Probably at 2dddf6f4133975af62e64cb6406ec1239491fa89, which was supposed
to be placed before switching to the migration thread (or even squashed
in it) but ended up much earlier when the project moved from me to Juan.


You mean by bisecting between qemu 1.2 and 1.3? I retested qemu 1.2 and
it wasn't 100% working for me there too. It worked fine until
migrate_downtime 1s it breaks / vm just halts when i set it to 2s with
qemu 1.2. So i don't really know where to start bisecting. As i have NO
version where it worked perfectly. Except Qemu 1.3 with the patches
backported from 1.4 this works fine.


Bisect between the two commits I gave above.  There probably will a
place when it starts failing reliably.

Paolo





[Qemu-devel] [Bug 1033727] Re: USB passthrough doesn't work anymore with qemu-kvm 1.1.1

2012-12-31 Thread Falk Seyboldt
same here with AVM ISDN-Controller FRITZ!Card v2.1 on openSUSE 12.2.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1033727

Title:
  USB passthrough doesn't work anymore with qemu-kvm 1.1.1

Status in QEMU:
  New
Status in “qemu-kvm” package in Ubuntu:
  Confirmed
Status in “qemu-kvm” package in Debian:
  Confirmed

Bug description:
  Hi,

  I have a "Bus 006 Device 002: ID 0d46:3003 Kobil Systems GmbH mIDentity Light 
/ KAAN SIM III" (kind of smart card) in an USB port which I make available to a 
Windows XP guest.
  This worked fine with every older qemu-kvm version I've used so far.

  But since 1.1.0 it doesn't work anymore.
  The device shows up in the guest, but the software can't access it anymore 
(and the guest is pretty unresponsive).

  On the host I get every 2 seconds this message:
  [ 7719.239528] usb 6-1: reset full-speed USB device number 2 using uhci_hcd

  Command line options are:
  /usr/bin/kvm
  ...
  -device usb-host,vendorid=0x0d46,productid=0x3003,bus=usb.0,port=3
  ...

  When I switch back to qemu-kvm 1.0.1 everything works fine again.
  Any idea what the problem could be?

  Thanks
  Klaus

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1033727/+subscriptions



[Qemu-devel] [Qemu-trivial] [PATCH] configure: try pkg-config for curses

2012-12-31 Thread Vadim Evard

configure: try pkg-config for curses

Static linkikng against ncurses may require explicit -ltinfo.
In case -lcurses and -lncurses both didn't work give pkg-config a
chance.

Signed-off-by: Vadim Evard 
---
 configure |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index b0c7e54..16280e2 100755
--- a/configure
+++ b/configure
@@ -2030,7 +2030,7 @@ fi
 if test "$mingw32" = "yes" ; then
 curses_list="-lpdcurses"
 else
-curses_list="-lncurses -lcurses"
+curses_list="-lncurses:-lcurses:$($pkg_config --libs ncurses)"
 fi

 if test "$curses" != "no" ; then
@@ -2043,7 +2043,9 @@ int main(void) {
   return s != 0;
 }
 EOF
+  IFS=:
   for curses_lib in $curses_list; do
+unset IFS
 if compile_prog "" "$curses_lib" ; then
   curses_found=yes
   libs_softmmu="$curses_lib $libs_softmmu"
--
1.7.10.4



[Qemu-devel] [PATCH v4 0/2] soft-float-fixes for target-s390x

2012-12-31 Thread Richard Henderson
Changes v3-v4:
  Rebase after source tree rearrangements.

Changes v2-v3:
  Ignore softfloat "style" completely.  Code now formatted per QEMU.

Changes v1-v2:
  Incorporating feedback from Peter Maydell (previously missed in
  the 140+ message thread).


r~


Richard Henderson (2):
  softfloat: Fix uint64_to_float64
  softfloat: Implement uint64_to_float128

 fpu/softfloat.c | 21 ++---
 include/fpu/softfloat.h |  3 +++
 2 files changed, 21 insertions(+), 3 deletions(-)

-- 
1.7.11.7




[Qemu-devel] [PATCH 1/2] softfloat: Fix uint64_to_float64

2012-12-31 Thread Richard Henderson
The interface to normalizeRoundAndPackFloat64 requires that the
high bit be clear.  Perform one shift-right-and-jam if needed.

Reviewed-by: Peter Maydell 
Signed-off-by: Richard Henderson 
---
 fpu/softfloat.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 0cfa6b4..20b05d4 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -1271,11 +1271,18 @@ float64 int64_to_float64( int64 a STATUS_PARAM )
 
 }
 
-float64 uint64_to_float64( uint64 a STATUS_PARAM )
+float64 uint64_to_float64(uint64 a STATUS_PARAM)
 {
-if ( a == 0 ) return float64_zero;
-return normalizeRoundAndPackFloat64( 0, 0x43C, a STATUS_VAR );
+int exp =  0x43C;
 
+if (a == 0) {
+return float64_zero;
+}
+if ((int64_t)a < 0) {
+shift64RightJamming(a, 1, &a);
+exp += 1;
+}
+return normalizeRoundAndPackFloat64(0, exp, a STATUS_VAR);
 }
 
 /*
-- 
1.7.11.7




[Qemu-devel] [PATCH 2/2] softfloat: Implement uint64_to_float128

2012-12-31 Thread Richard Henderson
Reviewed-by: Peter Maydell 
Signed-off-by: Richard Henderson 
---
 fpu/softfloat.c | 8 
 include/fpu/softfloat.h | 3 +++
 2 files changed, 11 insertions(+)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 20b05d4..ac3d150 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -1339,6 +1339,14 @@ float128 int64_to_float128( int64 a STATUS_PARAM )
 
 }
 
+float128 uint64_to_float128(uint64 a STATUS_PARAM)
+{
+if (a == 0) {
+return float128_zero;
+}
+return normalizeRoundAndPackFloat128(0, 0x406E, a, 0 STATUS_VAR);
+}
+
 /*
 | Returns the result of converting the single-precision floating-point value
 | `a' to the 32-bit two's complement integer format.  The conversion is
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index 0946f07..f3927e2 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -237,6 +237,7 @@ float64 int64_to_float64( int64 STATUS_PARAM );
 float64 uint64_to_float64( uint64 STATUS_PARAM );
 floatx80 int64_to_floatx80( int64 STATUS_PARAM );
 float128 int64_to_float128( int64 STATUS_PARAM );
+float128 uint64_to_float128( uint64 STATUS_PARAM );
 
 /*
 | Software half-precision conversion routines.
@@ -630,6 +631,8 @@ INLINE int float128_is_any_nan(float128 a)
 ((a.low != 0) || ((a.high & 0xLL) != 0));
 }
 
+#define float128_zero make_float128(0, 0)
+
 /*
 | The pattern for a default generated quadruple-precision NaN.
 **/
-- 
1.7.11.7




Re: [Qemu-devel] [PATCH] tcg: Remove unneeded assertion

2012-12-31 Thread Richard Henderson
On 2012-12-29 23:20, Stefan Weil wrote:
> Commit 7f6f0ae5b95adfa76e10eabe2c34424a955fd10c added two assertions.
> 
> One of these assertions is not needed:
> The pointer ts is never NULL because it is initialized with the
> address of an array element.
> 
> Signed-off-by: Stefan Weil 

Reviewed-by: Richard Henderson 

r~



[Qemu-devel] [PATCH 0/2] linux-user: dhclient support

2012-12-31 Thread Laurent Vivier
This two patches allow to use dhclient to configure IP addresses
in a linux container running the linux-user version of qemu.

[PATCH 1/2] linux-user: Add setsockopt(SO_ATTACH_FILTER)
[PATCH 2/2] linux-user: SOCK_PACKET uses network endian to encode



[Qemu-devel] [PATCH 1/2] linux-user: Add setsockopt(SO_ATTACH_FILTER)

2012-12-31 Thread Laurent Vivier
This is needed to be able to run dhclient.

Signed-off-by: Laurent Vivier 
---
 linux-user/syscall.c  |   34 +-
 linux-user/syscall_defs.h |   12 
 2 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index e99adab..000b640 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -98,6 +98,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base,
 #include 
 #include 
 #include 
+#include 
 #include "linux_loop.h"
 #include "cpu-uname.h"
 
@@ -1491,6 +1492,38 @@ static abi_long do_setsockopt(int sockfd, int level, int 
optname,
 break;
 case TARGET_SOL_SOCKET:
 switch (optname) {
+case TARGET_SO_ATTACH_FILTER: {
+struct target_sock_fprog *tfprog;
+struct target_sock_filter *tfilter;
+struct sock_fprog fprog;
+struct sock_filter *filter;
+int i;
+
+if (optlen != sizeof(*tfprog))
+return -TARGET_EINVAL;
+if (!lock_user_struct(VERIFY_READ, tfprog, optval_addr, 0))
+return -TARGET_EFAULT;
+if (!lock_user_struct(VERIFY_READ, tfilter,
+  tswapal(tfprog->filter), 0))
+return -TARGET_EFAULT;
+
+fprog.len = tswap16(tfprog->len);
+filter = alloca(fprog.len * sizeof(*filter));
+for (i = 0; i < fprog.len; i ++) {
+filter[i].code = tswap16(tfilter[i].code);
+filter[i].jt = tfilter[i].jt;
+filter[i].jf = tfilter[i].jf;
+filter[i].k = tswap32(tfilter[i].k);
+}
+fprog.filter = filter;
+
+ret = get_errno(setsockopt(sockfd, SOL_SOCKET,
+SO_ATTACH_FILTER, &fprog, sizeof(fprog)));
+
+unlock_user_struct(tfilter, tfprog->filter, 1);
+unlock_user_struct(tfprog, optval_addr, 1);
+return ret;
+}
 /* Options with 'int' argument.  */
 case TARGET_SO_DEBUG:
optname = SO_DEBUG;
@@ -1548,7 +1581,6 @@ static abi_long do_setsockopt(int sockfd, int level, int 
optname,
 case TARGET_SO_SNDTIMEO:
optname = SO_SNDTIMEO;
break;
-break;
 default:
 goto unimplemented;
 }
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index d4589e7..501735f 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -119,6 +119,18 @@ struct target_sockaddr {
 uint8_t sa_data[14];
 };
 
+struct target_sock_filter {
+target_ushort code;
+uint8_t jt;
+uint8_t jf;
+target_uint k;
+};
+
+struct target_sock_fprog {
+target_ushort len;
+abi_ulong filter;
+};
+
 struct target_in_addr {
 uint32_t s_addr; /* big endian */
 };
-- 
1.7.10.4




[Qemu-devel] [PATCH 2/2] linux-user: SOCK_PACKET uses network endian to encode protocol in socket()

2012-12-31 Thread Laurent Vivier
From: Laurent Vivier 

in PACKET(7) :
 protocol is the  IEEE  802.3  protocol
number in network order.  See the  include file for a
list of allowed protocols.  When protocol is  set  to  htons(ETH_P_ALL)
then all protocols are received.  All incoming packets of that protocol
type will be passed to the packet socket before they are passed to  the
protocols implemented in the kernel.

Signed-off-by: Laurent Vivier 
---
 include/exec/user/abitypes.h |   22 ++
 linux-user/syscall.c |8 +++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/include/exec/user/abitypes.h b/include/exec/user/abitypes.h
index fe7f662..f4f526a 100644
--- a/include/exec/user/abitypes.h
+++ b/include/exec/user/abitypes.h
@@ -15,6 +15,15 @@ static inline abi_ulong tswapal(abi_ulong v)
 return tswap32(v);
 }
 
+static inline abi_ulong abi_ntohl(abi_ulong v)
+{
+#if defined(HOST_BIG_ENDIAN)
+return v;
+#else
+return bswap_32(v);
+#endif
+}
+
 #else
 typedef target_ulong abi_ulong;
 typedef target_long abi_long;
@@ -32,5 +41,18 @@ static inline abi_ulong tswapal(abi_ulong v)
 return tswapl(v);
 }
 
+static inline abi_ulong abi_ntohl(abi_ulong v)
+{
+#if defined(HOST_BIG_ENDIAN)
+return v;
+#else
+#if TARGET_LONG_SIZE == 4
+return bswap_32(v);
+#else
+return bswap_64(v);
+#endif
+#endif
+}
+
 #endif
 #endif
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 000b640..29151a6 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1874,7 +1874,7 @@ static void unlock_iovec(struct iovec *vec, abi_ulong 
target_addr,
 }
 
 /* do_socket() Must return target values and target errnos. */
-static abi_long do_socket(int domain, int type, int protocol)
+static abi_long do_socket(int domain, int type, abi_ulong protocol)
 {
 #if defined(TARGET_MIPS)
 switch(type) {
@@ -1900,6 +1900,12 @@ static abi_long do_socket(int domain, int type, int 
protocol)
 #endif
 if (domain == PF_NETLINK)
 return -EAFNOSUPPORT; /* do not NETLINK socket connections possible */
+if (type == SOCK_PACKET) {
+/* in this case, socket() needs a network endian short */
+protocol = tswapal(protocol); /* restore network endian long */
+protocol = abi_ntohl(protocol); /* a host endian long */
+protocol = htons(protocol); /* network endian short */
+}
 return get_errno(socket(domain, type, protocol));
 }
 
-- 
1.7.10.4




[Qemu-devel] [PATCH] linux-user: correct print_timeval() swap tv_sec and tv_usec

2012-12-31 Thread Laurent Vivier
From: Laurent Vivier 

Signed-off-by: Laurent Vivier 
---
 linux-user/strace.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index 6ec90e8..4e91a6e 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -682,7 +682,7 @@ print_timeval(abi_ulong tv_addr, int last)
 if (!tv)
 return;
 gemu_log("{" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "}%s",
-tv->tv_sec, tv->tv_usec, get_comma(last));
+tswapal(tv->tv_sec), tswapal(tv->tv_usec), get_comma(last));
 unlock_user(tv, tv_addr, 0);
 } else
 gemu_log("NULL%s", get_comma(last));
-- 
1.7.10.4




Re: [Qemu-devel] [Virt-test-devel] [Autotest PATCH 1/2] virt run: fix typo in help message

2012-12-31 Thread Lucas Meneghel Rodrigues
Ok, this looks good, applied, thanks!

On Sat, Dec 29, 2012 at 11:02 PM, Amos Kong  wrote:
> type 'kvm' already been changed to 'qemu'
>
> Signed-off-by: Amos Kong 
> ---
>  run |4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/run b/run
> index 97dcdad..aac332a 100755
> --- a/run
> +++ b/run
> @@ -145,7 +145,7 @@ class VirtTestRunParser(optparse.OptionParser):
>  general.add_option("-v", "--verbose", action="store_true",
> dest="verbose", help="Exhibit debug messages")
>  general.add_option("-t", "--type", action="store", dest="type",
> -   help="Choose test type (kvm, libvirt, v2v)")
> +   help="Choose test type (qemu, libvirt, v2v)")
>  general.add_option("-c", "--config", action="store", dest="config",
> help="Explicitly choose a cartesian config")
>  general.add_option("-r", "--restore-image", action="store_true",
> @@ -174,7 +174,7 @@ class VirtTestRunParser(optparse.OptionParser):
>   "%default"))
>  self.add_option_group(general)
>
> -qemu = optparse.OptionGroup(self, 'Options specific to the kvm test')
> +qemu = optparse.OptionGroup(self, 'Options specific to the qemu 
> test')
>  qemu.add_option("--qemu-bin", action="store", dest="qemu",
>  help=("Path to a custom qemu binary to be tested. "
>"Default path: %s" % qemu_bin_path))
> --
> 1.7.1
>
> ___
> Virt-test-devel mailing list
> virt-test-de...@redhat.com
> https://www.redhat.com/mailman/listinfo/virt-test-devel



-- 
Lucas



[Qemu-devel] [PATCH] linux-user: correct setsockopt() SO_SNDTIMEO and SO_RCVTIMEO take a struct timeval, not an int

2012-12-31 Thread Laurent Vivier
From: Laurent Vivier 

Signed-off-by: Laurent Vivier 
---
 linux-user/syscall.c |   26 +++---
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index e99adab..1530c8f 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1491,6 +1491,25 @@ static abi_long do_setsockopt(int sockfd, int level, int 
optname,
 break;
 case TARGET_SOL_SOCKET:
 switch (optname) {
+case TARGET_SO_RCVTIMEO: {
+struct timeval tv;
+
+   optname = SO_RCVTIMEO;
+
+set_timeout:
+if (optlen != sizeof(struct target_timeval))
+return -TARGET_EINVAL;
+
+if (copy_from_user_timeval(&tv, optval_addr))
+return -TARGET_EFAULT;
+
+   ret = get_errno(setsockopt(sockfd, SOL_SOCKET, optname,
+&tv, sizeof(tv)));
+   return ret;
+}
+case TARGET_SO_SNDTIMEO:
+   optname = SO_SNDTIMEO;
+   goto set_timeout;
 /* Options with 'int' argument.  */
 case TARGET_SO_DEBUG:
optname = SO_DEBUG;
@@ -1542,13 +1561,6 @@ static abi_long do_setsockopt(int sockfd, int level, int 
optname,
 case TARGET_SO_RCVLOWAT:
optname = SO_RCVLOWAT;
break;
-case TARGET_SO_RCVTIMEO:
-   optname = SO_RCVTIMEO;
-   break;
-case TARGET_SO_SNDTIMEO:
-   optname = SO_SNDTIMEO;
-   break;
-break;
 default:
 goto unimplemented;
 }
-- 
1.7.10.4




Re: [Qemu-devel] [Autotest PATCH 2/2] virt run: add three logical case filters

2012-12-31 Thread Lucas Meneghel Rodrigues
Hmmm, about this one, I'm worried about making things more complex...

The way I see the problem at hand, I'd say if people want to customize
things, they'd be better of creating their own, specialized config
files rather than adding command line flags to manipulate the test
sets.

So my initial stand on this particular patch is NACK, but you might
convince me otherwise :)

On Sat, Dec 29, 2012 at 11:10 PM, Amos Kong  wrote:
> On Sun, Dec 30, 2012 at 09:02:09AM +0800, Amos Kong wrote:
>> This patch added there options for filtering cases by logics,
>>
>> For example:
>> ./run -t qemu -c tests.cfg --oronly="WinXP Win7" --andonly="boot 64" 
>> --not="sp1"
>
> Oh! a typo in commitlog
>
>  ./run -t qemu -c tests.cfg --or="WinXP Win7" --and="boot 64" --not="sp1"
>
>>   (following cases will be executed)
>>
>> Test1: virtio_blk.smp2.virtio_net.WinXP.64.boot
>> Test2: virtio_blk.smp2.virtio_net.Win7.64.boot
> ...
>
> Amos
>



-- 
Lucas



[Qemu-devel] [PATCH] linux-user: improve print_fcntl()

2012-12-31 Thread Laurent Vivier
From: Laurent Vivier 

Signed-off-by: Laurent Vivier 
---
 linux-user/strace.c |   97 +--
 1 file changed, 79 insertions(+), 18 deletions(-)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index 6ec90e8..039fee8 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -462,18 +462,6 @@ UNUSED static struct flags mmap_flags[] = {
 FLAG_END,
 };
 
-UNUSED static struct flags fcntl_flags[] = {
-FLAG_TARGET(F_DUPFD),
-FLAG_TARGET(F_GETFD),
-FLAG_TARGET(F_SETFD),
-FLAG_TARGET(F_GETFL),
-FLAG_TARGET(F_SETFL),
-FLAG_TARGET(F_GETLK),
-FLAG_TARGET(F_SETLK),
-FLAG_TARGET(F_SETLKW),
-FLAG_END,
-};
-
 UNUSED static struct flags clone_flags[] = {
 FLAG_GENERIC(CLONE_VM),
 FLAG_GENERIC(CLONE_FS),
@@ -867,12 +855,85 @@ print_fcntl(const struct syscallname *name,
 {
 print_syscall_prologue(name);
 print_raw_param("%d", arg0, 0);
-print_flags(fcntl_flags, arg1, 0);
-/*
- * TODO: check flags and print following argument only
- *   when needed.
- */
-print_pointer(arg2, 1);
+switch(arg1) {
+case TARGET_F_DUPFD:
+gemu_log("F_DUPFD,");
+print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
+break;
+case TARGET_F_GETFD:
+gemu_log("F_GETFD");
+break;
+case TARGET_F_SETFD:
+gemu_log("F_SETFD,");
+print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
+break;
+case TARGET_F_GETFL:
+gemu_log("F_GETFL");
+break;
+case TARGET_F_SETFL:
+gemu_log("F_SETFL,");
+print_open_flags(arg2, 1);
+break;
+case TARGET_F_GETLK:
+gemu_log("F_GETLK,");
+print_pointer(arg2, 1);
+break;
+case TARGET_F_SETLK:
+gemu_log("F_SETLK,");
+print_pointer(arg2, 1);
+break;
+case TARGET_F_SETLKW:
+gemu_log("F_SETLKW,");
+print_pointer(arg2, 1);
+break;
+case TARGET_F_GETOWN:
+gemu_log("F_GETOWN");
+break;
+case TARGET_F_SETOWN:
+gemu_log("F_SETOWN,");
+print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
+break;
+case TARGET_F_GETSIG:
+gemu_log("F_GETSIG");
+break;
+case TARGET_F_SETSIG:
+gemu_log("F_SETSIG,");
+print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
+break;
+#if TARGET_ABI_BITS == 32
+case TARGET_F_GETLK64:
+gemu_log("F_GETLK64,");
+print_pointer(arg2, 1);
+break;
+case TARGET_F_SETLK64:
+gemu_log("F_SETLK64,");
+print_pointer(arg2, 1);
+break;
+case TARGET_F_SETLKW64:
+gemu_log("F_SETLKW64,");
+print_pointer(arg2, 1);
+break;
+#endif
+case TARGET_F_SETLEASE:
+gemu_log("F_SETLEASE,");
+print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
+break;
+case TARGET_F_GETLEASE:
+gemu_log("F_GETLEASE");
+break;
+case TARGET_F_DUPFD_CLOEXEC:
+gemu_log("F_DUPFD_CLOEXEC,");
+print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
+break;
+case TARGET_F_NOTIFY:
+gemu_log("F_NOTIFY,");
+print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
+break;
+default:
+print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
+print_pointer(arg2, 1);
+break;
+}
 print_syscall_epilogue(name);
 }
 #define print_fcntl64   print_fcntl
-- 
1.7.10.4




[Qemu-devel] Using QEMU guest agent to run programs from guest path

2012-12-31 Thread Erlon Cruz
Hi,


I needed to run an external program in a guest machine. Once this must be
triggered by the host, I first thought in qemu-ga.
Is that possible? In QEMU help page and in the code I couldn't find such
capability.
So Im thinking In to implement a new GA QMP command that can run generic
programs in the guest. It would be receive/return something like this:

{"execute":"execvp",
"arguments":{"command":"/bin/ls","cmdargs":"-la","timeout":20}}
{"return": {"status": "0", "stdout": "aGVsbG8gd29ybGQhCg==", "stderr": ""}}

Any thoughts/ideas about this?

Kind Regards,
Erlon


[Qemu-devel] qemu-ga command listing

2012-12-31 Thread Eric Blake
Is there a guest-agent command for querying the list of available
commands for a given guest agent?  If not, should there be?  In other
words, I'm looking for the counterpart to QMP {"execute":"query-commands"}.

-- 
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 1/2] linux-user: Add setsockopt(SO_ATTACH_FILTER)

2012-12-31 Thread Peter Maydell
On 31 December 2012 19:37, Laurent Vivier  wrote:
> This is needed to be able to run dhclient.
>
> Signed-off-by: Laurent Vivier 
> ---
>  linux-user/syscall.c  |   34 +-
>  linux-user/syscall_defs.h |   12 
>  2 files changed, 45 insertions(+), 1 deletion(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index e99adab..000b640 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -98,6 +98,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base,
>  #include 
>  #include 
>  #include 
> +#include 
>  #include "linux_loop.h"
>  #include "cpu-uname.h"
>
> @@ -1491,6 +1492,38 @@ static abi_long do_setsockopt(int sockfd, int level, 
> int optname,
>  break;
>  case TARGET_SOL_SOCKET:
>  switch (optname) {
> +case TARGET_SO_ATTACH_FILTER: {

This brace should go on a line of its own (lined up with the 'c' in case) IMHO.

> +struct target_sock_fprog *tfprog;
> +struct target_sock_filter *tfilter;
> +struct sock_fprog fprog;
> +struct sock_filter *filter;
> +int i;
> +
> +if (optlen != sizeof(*tfprog))
> +return -TARGET_EINVAL;

QEMU style requires braces on this if. You can use checkpatch.pl
to catch this kind of thing.

> +if (!lock_user_struct(VERIFY_READ, tfprog, optval_addr, 0))
> +return -TARGET_EFAULT;
> +if (!lock_user_struct(VERIFY_READ, tfilter,
> +  tswapal(tfprog->filter), 0))
> +return -TARGET_EFAULT;

This will fail to unlock tfprog in the failure case.

> +
> +fprog.len = tswap16(tfprog->len);
> +filter = alloca(fprog.len * sizeof(*filter));

Not sure an unconstrained-size alloca based on data from
the guest binary is a fantastic idea (though we no doubt
do something similar for some other syscalls).

> +for (i = 0; i < fprog.len; i ++) {
> +filter[i].code = tswap16(tfilter[i].code);
> +filter[i].jt = tfilter[i].jt;
> +filter[i].jf = tfilter[i].jf;
> +filter[i].k = tswap32(tfilter[i].k);
> +}
> +fprog.filter = filter;
> +
> +ret = get_errno(setsockopt(sockfd, SOL_SOCKET,
> +SO_ATTACH_FILTER, &fprog, sizeof(fprog)));
> +
> +unlock_user_struct(tfilter, tfprog->filter, 1);
> +unlock_user_struct(tfprog, optval_addr, 1);
> +return ret;
> +}
>  /* Options with 'int' argument.  */
>  case TARGET_SO_DEBUG:
> optname = SO_DEBUG;
> @@ -1548,7 +1581,6 @@ static abi_long do_setsockopt(int sockfd, int level, 
> int optname,
>  case TARGET_SO_SNDTIMEO:
> optname = SO_SNDTIMEO;
> break;
> -break;

Nice catch, but this is an unrelated change that should go in its own patch.

>  default:
>  goto unimplemented;
>  }

-- PMM



Re: [Qemu-devel] [PATCH 2/2] linux-user: SOCK_PACKET uses network endian to encode protocol in socket()

2012-12-31 Thread Peter Maydell
On 31 December 2012 19:38, Laurent Vivier  wrote:
> @@ -1900,6 +1900,12 @@ static abi_long do_socket(int domain, int type, int 
> protocol)
>  #endif
>  if (domain == PF_NETLINK)
>  return -EAFNOSUPPORT; /* do not NETLINK socket connections possible 
> */
> +if (type == SOCK_PACKET) {
> +/* in this case, socket() needs a network endian short */
> +protocol = tswapal(protocol); /* restore network endian long */
> +protocol = abi_ntohl(protocol); /* a host endian long */
> +protocol = htons(protocol); /* network endian short */
> +}

Are you sure this is correct for little endian guests? I've only
desk-checked it rather than running a test program, but it looks
to me like you end up passing the wrong value to socket().

Also it seems rather involved since we swap things three times and
have an entirely new abi_* function. Either I'm completely confused
or it should be enough to just have

if (type == SOCK_PACKET) {
  protocol = tswap16(protocol);
}

-- PMM



Re: [Qemu-devel] [PATCH] linux-user: correct setsockopt() SO_SNDTIMEO and SO_RCVTIMEO take a struct timeval, not an int

2012-12-31 Thread Peter Maydell
On 31 December 2012 19:53, Laurent Vivier  wrote:
> From: Laurent Vivier 

Looks about right (though the goto is a little ugly). You have some
style issues you need to fix, though.

thanks
-- PMM



[Qemu-devel] [Bug 1094950] [NEW] crash at qemu_iohandler_poll (iohandler.c:124) on macos 10.8.2

2012-12-31 Thread Christopher Mason
Public bug reported:

I'm seeing consistent hangs / crashes on MacOS 10.8.2 with 1.3.0.  I've
tried both gcc-4.2 and clang.  I've tried a half a dozen different
images/kernels.

I configured qemu like this:

./configure --disable-sdl --disable-kvm --enable-cocoa --cc=gcc-4.2
--host-cc=gcc-4.2 --enable-debug   --extra-cflags=-g   --extra-
ldflags=-g

And ran it like this:

qemu-system-arm -nographic -M versatilepb -kernel
vmlinuz-2.6.32-5-versatile -initrd initrd.img-2.6.32-5-versatile -hda
debian_squeeze_armel_standard.qcow2 -append "root=/dev/sda1
console=ttyAMA0"

With images, kernel, and initrd described here:

http://psellos.com/2012/08/2012.08.qemu-arm-osx.html

And I get:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00010142f2d0
0x00010142f2d0 in ?? ()

(gdb) bt
#0  0x00010142f2d0 in ?? ()
#1  0x00010016e209 in qemu_iohandler_poll (readfds=0x10097ca00, 
writefds=0x10097ca80, xfds=0x10097cb00, ret=4) at iohandler.c:124
#2  0x000100172acf in main_loop_wait (nonblocking=0) at main-loop.c:418
#3  0x000100207bbf in main_loop () at vl.c:1765
#4  0x00010020e7b0 in qemu_main (argc=12, argv=0x7fff5fbff360, 
envp=0x7fff5fbff3c8) at vl.c:3992
#5  0x0001001d6013 in main (argc=12, argv=0x7fff5fbff360) at ui/cocoa.m:884
(gdb) frame 1
#1  0x00010016e209 in qemu_iohandler_poll (readfds=0x10097ca00, 
writefds=0x10097ca80, xfds=0x10097cb00, ret=4) at iohandler.c:124
124 ioh->fd_read(ioh->opaque);
Current language:  auto; currently c
(gdb) p ioh
$1 = (IOHandlerRecord *) 0x10142f110
(gdb) p *ioh
$2 = {
  fd_read_poll = 0, 
  fd_read = 0x10017212b , 
  fd_write = 0, 
  opaque = 0x3, 
  next = {
le_next = 0x0, 
le_prev = 0x105d00bc0
  }, 
  fd = 3, 
  deleted = false
}

** Affects: qemu
 Importance: Undecided
 Status: New

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1094950

Title:
  crash at  qemu_iohandler_poll (iohandler.c:124) on macos 10.8.2

Status in QEMU:
  New

Bug description:
  I'm seeing consistent hangs / crashes on MacOS 10.8.2 with 1.3.0.
  I've tried both gcc-4.2 and clang.  I've tried a half a dozen
  different images/kernels.

  I configured qemu like this:

  ./configure --disable-sdl --disable-kvm --enable-cocoa --cc=gcc-4.2
  --host-cc=gcc-4.2 --enable-debug   --extra-cflags=-g   --extra-
  ldflags=-g

  And ran it like this:

  qemu-system-arm -nographic -M versatilepb -kernel
  vmlinuz-2.6.32-5-versatile -initrd initrd.img-2.6.32-5-versatile -hda
  debian_squeeze_armel_standard.qcow2 -append "root=/dev/sda1
  console=ttyAMA0"

  With images, kernel, and initrd described here:

  http://psellos.com/2012/08/2012.08.qemu-arm-osx.html

  And I get:

  Program received signal EXC_BAD_ACCESS, Could not access memory.
  Reason: KERN_PROTECTION_FAILURE at address: 0x00010142f2d0
  0x00010142f2d0 in ?? ()

  (gdb) bt
  #0  0x00010142f2d0 in ?? ()
  #1  0x00010016e209 in qemu_iohandler_poll (readfds=0x10097ca00, 
writefds=0x10097ca80, xfds=0x10097cb00, ret=4) at iohandler.c:124
  #2  0x000100172acf in main_loop_wait (nonblocking=0) at main-loop.c:418
  #3  0x000100207bbf in main_loop () at vl.c:1765
  #4  0x00010020e7b0 in qemu_main (argc=12, argv=0x7fff5fbff360, 
envp=0x7fff5fbff3c8) at vl.c:3992
  #5  0x0001001d6013 in main (argc=12, argv=0x7fff5fbff360) at 
ui/cocoa.m:884
  (gdb) frame 1
  #1  0x00010016e209 in qemu_iohandler_poll (readfds=0x10097ca00, 
writefds=0x10097ca80, xfds=0x10097cb00, ret=4) at iohandler.c:124
  124   ioh->fd_read(ioh->opaque);
  Current language:  auto; currently c
  (gdb) p ioh
  $1 = (IOHandlerRecord *) 0x10142f110
  (gdb) p *ioh
  $2 = {
fd_read_poll = 0, 
fd_read = 0x10017212b , 
fd_write = 0, 
opaque = 0x3, 
next = {
  le_next = 0x0, 
  le_prev = 0x105d00bc0
}, 
fd = 3, 
deleted = false
  }

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1094950/+subscriptions



Re: [Qemu-devel] [PATCH 2/2] linux-user: SOCK_PACKET uses network endian to encode protocol in socket()

2012-12-31 Thread Laurent Vivier
Le lundi 31 décembre 2012 à 21:32 +, Peter Maydell a écrit :
> On 31 December 2012 19:38, Laurent Vivier  wrote:
> > @@ -1900,6 +1900,12 @@ static abi_long do_socket(int domain, int type, int 
> > protocol)
> >  #endif
> >  if (domain == PF_NETLINK)
> >  return -EAFNOSUPPORT; /* do not NETLINK socket connections 
> > possible */
> > +if (type == SOCK_PACKET) {
> > +/* in this case, socket() needs a network endian short */
> > +protocol = tswapal(protocol); /* restore network endian long */
> > +protocol = abi_ntohl(protocol); /* a host endian long */
> > +protocol = htons(protocol); /* network endian short */
> > +}
> 
> Are you sure this is correct for little endian guests? I've only
> desk-checked it rather than running a test program, but it looks
> to me like you end up passing the wrong value to socket().

I tried to find a solution working in every case.

> Also it seems rather involved since we swap things three times and
> have an entirely new abi_* function. Either I'm completely confused
> or it should be enough to just have
> 
> if (type == SOCK_PACKET) {
>   protocol = tswap16(protocol);
> }

works... sometime. In fact, work if target endianess is network endianess.

Correct me if I'm wrong.

target  host
little endian / big endian

memory   00 00 00 03
protocol 0300
tswap16   -> don't work

tswapal()   0003
abi_ntohl() 0003
htons() 0003 -> work

big endian / little endian:

memory00 00 00 03
protocol  0003
tswap16() 0300 -> work

tswapal() 0300
abi_ntohl() 0003
htons() 0300 -> work

little endian/little endian:

memory: 00 00 00 03 (network endian)
protocol : 0300
tswap16() :  -> don't work

tswapal() 0300
abi_ntohl() 0003
htons() 0300 -> work

big endian / big endian

memory 00 00 00 03
protocol 0003
tswap16() 0003 -> work

tswapal() 0003
abi_ntohl() 0003
htons() 0003 -> work

Laurent

-- 
"Just play. Have fun. Enjoy the game."
- Michael Jordan




[Qemu-devel] Fwd: Problem booting 32 bit guest on 64 bit host using kvm

2012-12-31 Thread Mark Blakeney
Hi, I am inexperienced using QEMU and hoping somebody here can help me.

Some time ago I cloned a disk image of an old Solaris legacy system and was
able to successfully boot and use it within QEMU. Recently I upgraded my
host from i386 Ubuntu 12.04 to a new box running x86_64 Ubuntu 12.10. Now I
find that the same qemu command line results in that guest failing to boot
with a "no active boot partition" error message.

The command I have been using is:

qemu-system-i386 \
  -machine pc,accel=kvm \
  -m 256M \
  -vga std \
  -net nic,vlan=1,model=pcnet \
  -net user,vlan=1,hostfwd=::8050-$GUEST:22 \
  -hda "$DISK"

I find that if I change to "accel=tcg" in above command (or add -no-kvm)
then the guest will boot ok but I find my host works much harder & slower
than when I use kvm. Is there a qemu option so I can use kvm but get around
this guest boot issue?

Thanks,

--
Mark.