Skip to contentSkip to conversation

Trivial-patches pull request for 2013-06-14

GIT PULL Michael Tokarev 2 participants 29 messages Jun 14, 2013 – Jun 17, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

This is yet another pull request from the trivial-patches queue. There are many changes this time, most are really trivial, but some, while also of trivial nature, are large(ish). These include:

- linux headers update request, which syncs copy of linux headers with 3.10-rc5, together with 3 preparational changes

- "char/serial: serial_ioport_write: Factor out common code" by Peter Crosthwaite, which is large but it removes ad-hoc implementation and uses generic bits instead

- "create qemu_openpty_raw() helper function and move it to a separate file" by Michael Tokarev, which is also a bit large but it just moves common code into a separate file.

It all appears to build (on OpenBSD, FreeBSD, OpenIndiana and Linux) and work, as far as I can tell.

Please pull.

Thanks,

/mjt

The following changes since commit bd5c51ee6c4f1c79cae5ad2516d711a27b4ea8ec:

qemu-char: don't issue CHR_EVENT_OPEN in a BH (2013-06-10 11:38:37 -0500)

are available in the git repository at:

git://git.corpit.ru/qemu.git trivial-patches-next

for you to fetch changes up to ba275adba09adfc0f7ec533f1fddba678d9ba826:

piix: fix some printf errors when debug is enabled (2013-06-14 14:38:45 +0400)

----------------------------------------------------------------
Alexey Kardashevskiy (3):
KVM: ARM: Add dummy kvm_arch_init_irq_routing()
KVM: S390: Add dummy kvm_arch_init_irq_routing()
linux-headers: Update to v3.10-rc5

Alon Levy (1):
libcacard/vscclient: fix leakage of socket on error paths

Andreas Färber (1):
Makefile: Install qemu-img and qemu-nbd man pages only if built

Ed Maste (2):
configure: remove ${config_host_ld} variable
configure: Disable host-bsd USB on FreeBSD

Hervé Poussineau (1):
cputlb: fix debug logs

Hu Tao (1):
piix: fix some printf errors when debug is enabled

Michael Tokarev (4):
qemu-char: remove a few needless #includes
gitignore: unignore *.patch
main-loop: do not include slirp/slirp.h, use libslirp.h instead create qemu_openpty_raw() helper function and move it to a separate file

Peter Crosthwaite (4):
intc/xilinx_intc: Use qemu_set_irq char/serial: cosmetic fixes.
char/serial: Use generic Fifo8
char/serial: serial_ioport_write: Factor out common code

Peter Wu (2):
gtk: implement -full-screen
Unbreak -no-quit for GTK, validate SDL options

Richard W.M. Jones (1):
curl: Whitespace only changes.

Scott Wood (1):
KVM: PPC: Add dummy kvm_arch_init_irq_routing()

Stefan Hajnoczi (1):
ivshmem: add missing error exit(2)

Stefan Weil (4):
device tree: Fix cppcheck warning
hw/scsi: Don't increment a boolean value
target-sparc: Replace free by g_free
hw/xen: Use g_free instead of free and fix potential memory leaks

 .gitignore                        |    1 -
 Makefile                          |    5 +-
 block/curl.c                      |    4 +-
 configure                         |    7 +--
 cputlb.c                          |    4 +-
 device_tree.c                     |    2 +-
 hw/acpi/piix4.c                   |   12 ++---
 hw/char/serial.c                  |  128 +++++++++++++++++++-----------------------------
 hw/intc/xilinx_intc.c             |    6 +--
 hw/misc/ivshmem.c                 |    1 +
 hw/scsi/vmw_pvscsi.c              |    2 +-
 hw/xen/xen_pt_config_init.c       |    4 +-
 include/hw/char/serial.h          |   15 ++----
 include/qemu-common.h             |   15 +-----
 include/ui/console.h              |    2 +-
 libcacard/vscclient.c             |    9 +++-
 linux-headers/asm-arm/kvm.h       |   12 ++---
 linux-headers/asm-mips/kvm.h      |  138 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 linux-headers/asm-mips/kvm_para.h |    1 +
 linux-headers/asm-powerpc/kvm.h   |   89 +++++++++++++++++++++++++++++++++
 linux-headers/asm-x86/kvm.h       |    1 -
 linux-headers/linux/kvm.h         |   42 +++++++++++++---
 linux-headers/linux/vfio.h        |    1 +
 linux-headers/linux/vhost.h       |   28 +++++++++++
 main-loop.c                       |    3 +-
 qemu-char.c                       |   79 ++----------------------------
 target-arm/kvm.c                  |    4 ++
 target-ppc/kvm.c                  |    4 ++
 target-s390x/kvm.c                |    4 ++
 target-sparc/cpu.c                |    2 +-
 ui/gtk.c                          |   18 +++----
 util/Makefile.objs                |    2 +-
 util/qemu-openpty.c               |  135 ++++++++++++++++++++++++++++++++++++++++++++++++++
 vl.c                              |   17 ++++---
 xen-all.c                         |    8 +--
 35 files changed, 569 insertions(+), 236 deletions(-)
 create mode 100644 linux-headers/asm-mips/kvm.h
 create mode 100644 linux-headers/asm-mips/kvm_para.h
 create mode 100644 util/qemu-openpty.c
#1 lore raw

[Qemu-devel] [PULL 01/26] qemu-char: remove a few needless #includes

This removes <syslog.h> since we don't use syslogging, and removes second, solaris-specific, include of <net/if.h> (which is included in a common part of the file)

---
 qemu-char.c |    2 --
 1 file changed, 2 deletions(-)
qemu-char.c +0 -2
index 0b6ae95..596bf9e 100644
@@ -76,8 +76,6 @@
 #include <netinet/ip_icmp.h> // must come after ip.h
 #include <netinet/udp.h>
 #include <netinet/tcp.h>
-#include <net/if.h>
-#include <syslog.h>
 #endif
 #endif
 #endif
Signature · 1 line
1.7.10.4
#2 lore raw

[Qemu-devel] [PULL 02/26] gitignore: unignore *.patch

In reply to Michael Tokarev

This partially reverts:

commit 082369e62c5bbaba89f173c2b803bc24115bb111
Author: liguang <[email protected]>
Date: Fri Mar 22 16:44:13 2013 +0800

gitignore: ignore more files

I'm not sure how this went in. The thing is that
ignoring *.patch, in my opinion, is just wrong.
Especially for downstreams who apply patches for
real.

---
 .gitignore |    1 -
 1 file changed, 1 deletion(-)
.gitignore +0 -1
index 64e9466..0fe114d 100644
@@ -82,7 +82,6 @@ fsdev/virtfs-proxy-helper.pod
 *.swp
 *.orig
 .pc
-*.patch
 *.gcda
 *.gcno
 patches
Signature · 1 line
1.7.10.4
#3 lore raw

[Qemu-devel] [PULL 03/26] configure: remove ${config_host_ld} variable

In reply to Michael Tokarev

From: Ed Maste <[email protected]>

It was only used in one place (and already expanded in one other).

---
 configure |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
configure +1 -2
index 1654413..e197b91 100755
@@ -3556,7 +3556,6 @@ echo "-> Your SDL version is too old - please upgrade to have SDL support"
 fi
 
 config_host_mak="config-host.mak"
-config_host_ld="config-host.ld"
 
 echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
 
@@ -4071,7 +4070,7 @@ if test "$gcov" = "yes" ; then
 fi
 
 # generate list of library paths for linker script
-$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
+$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > config-host.ld
 
 # use included Linux headers
 if test "$linux" = "yes" ; then
Signature · 1 line
1.7.10.4
#4 lore raw

[Qemu-devel] [PULL 04/26] configure: Disable host-bsd USB on FreeBSD

In reply to Michael Tokarev

From: Ed Maste <[email protected]>

It hasn't built since FreeBSD 8.x, and is disabled by a patch in the FreeBSD ports tree. FreeBSD is migrating to QEMU's libusb support.

---
 configure |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
configure +3 -1
index e197b91..a3f0b7a 100755
@@ -553,7 +553,9 @@ esac
 
 if [ "$bsd" = "yes" ] ; then
   if [ "$darwin" != "yes" ] ; then
-    usb="bsd"
+    if [ "$targetos" != "FreeBSD" ]; then
+      usb="bsd"
+    fi
     bsd_user="yes"
   fi
 fi
Signature · 1 line
1.7.10.4
#5 lore raw

[Qemu-devel] [PULL 05/26] intc/xilinx_intc: Use qemu_set_irq

In reply to Michael Tokarev

From: Peter Crosthwaite <[email protected]>

Use qemu_set_irq rather than if-elsing qemu_irq_(lower|raise). No functional change, just reduces verbosity.

---
 hw/intc/xilinx_intc.c |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
hw/intc/xilinx_intc.c +1 -5
index b106e72..5df7008 100644
@@ -66,11 +66,7 @@ static void update_irq(struct xlx_pic *p)
         i = ~0;
 
     p->regs[R_IVR] = i;
-    if ((p->regs[R_MER] & 1) && p->regs[R_IPR]) {
-        qemu_irq_raise(p->parent_irq);
-    } else {
-        qemu_irq_lower(p->parent_irq);
-    }
+    qemu_set_irq(p->parent_irq, (p->regs[R_MER] & 1) && p->regs[R_IPR]);
 }
 
 static uint64_t
Signature · 1 line
1.7.10.4
#6 lore raw
In reply to Michael Tokarev
Quoted 3 lines · Michael Tokarev

are available in the git repository at:

git://git.corpit.ru/qemu.git trivial-patches-next

And this is the same as

git://git.corpit.ru/qemu.git trivial-patches

*Sigh*.

/mjt

#7 lore raw

[Qemu-devel] [PULL 12/26] Makefile: Install qemu-img and qemu-nbd man pages only if built

In reply to Michael Tokarev

From: Andreas Färber <[email protected]>

When splitting openSUSE's qemu and qemu-linux-user packages we noticed that for linux-user-only builds unrelated man pages got installed. It's surely possible to delete them before packaging, but not installing them in the first place seems more logical.

---
 Makefile |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Makefile +4 -1
index 306e7bd..3cfa7d0 100644
@@ -306,10 +306,13 @@ install-doc: $(DOCS)
 	$(INSTALL_DATA) QMP/qmp-commands.txt "$(DESTDIR)$(qemu_docdir)"
 ifdef CONFIG_POSIX
 	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
-	$(INSTALL_DATA) qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1"
+	$(INSTALL_DATA) qemu.1 "$(DESTDIR)$(mandir)/man1"
+ifneq ($(TOOLS),)
+	$(INSTALL_DATA) qemu-img.1 "$(DESTDIR)$(mandir)/man1"
 	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
 	$(INSTALL_DATA) qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
 endif
+endif
 ifdef CONFIG_VIRTFS
 	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
 	$(INSTALL_DATA) fsdev/virtfs-proxy-helper.1 "$(DESTDIR)$(mandir)/man1"
Signature · 1 line
1.7.10.4
#8 lore raw

[Qemu-devel] [PULL 19/26] KVM: S390: Add dummy kvm_arch_init_irq_routing()

In reply to Michael Tokarev

From: Alexey Kardashevskiy <[email protected]>

The common KVM code insists on calling kvm_arch_init_irq_routing() as soon as it sees kernel header support for it (regardless of whether QEMU supports it). Provide a dummy function to satisfy this.

---
 target-s390x/kvm.c |    4 ++++
 1 file changed, 4 insertions(+)
target-s390x/kvm.c +4 -0
index 862fb12..4d9ac4a 100644
@@ -928,3 +928,7 @@ void kvm_s390_enable_css_support(S390CPU *cpu)
     r = kvm_vcpu_ioctl(CPU(cpu), KVM_ENABLE_CAP, &cap);
     assert(r == 0);
 }
+
+void kvm_arch_init_irq_routing(KVMState *s)
+{
+}
Signature · 1 line
1.7.10.4
#9 lore raw

[Qemu-devel] [PULL 11/26] Unbreak -no-quit for GTK, validate SDL options

In reply to Michael Tokarev

From: Peter Wu <[email protected]>

Certain options (-no-frame, -alt-grab, -ctrl-grab) only make sense with SDL. When compiling without SDL, these options (and -no-quit) print an error message and exit qemu.

In case QEMU is compiled with SDL support, the three aforementioned options still do not make sense with other display types. This patch addresses that issue by printing a warning. I have chosen not to exit QEMU afterwards because having the option is not harmful and before this patch it would be ignored anyway.

By delaying the sanity check from compile-time with some ifdefs to run-time, -no-quit is now also properly supported when compiling without SDL.

---
 vl.c |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
vl.c +10 -5
index 169c807..9f8fd6e 100644
@@ -3524,7 +3524,6 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_full_screen:
                 full_screen = 1;
                 break;
-#ifdef CONFIG_SDL
             case QEMU_OPTION_no_frame:
                 no_frame = 1;
                 break;
@@ -3537,14 +3536,11 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_no_quit:
                 no_quit = 1;
                 break;
+#ifdef CONFIG_SDL
             case QEMU_OPTION_sdl:
                 display_type = DT_SDL;
                 break;
 #else
-            case QEMU_OPTION_no_frame:
-            case QEMU_OPTION_alt_grab:
-            case QEMU_OPTION_ctrl_grab:
-            case QEMU_OPTION_no_quit:
             case QEMU_OPTION_sdl:
                 fprintf(stderr, "SDL support is disabled\n");
                 exit(1);
@@ -4085,6 +4081,15 @@ int main(int argc, char **argv, char **envp)
 #endif
     }
 
+    if ((no_frame || alt_grab || ctrl_grab) && display_type != DT_SDL) {
+        fprintf(stderr, "-no-frame, -alt-grab and -ctrl-grab are only valid "
+                        "for SDL, ignoring option\n");
+    }
+    if (no_quit && (display_type != DT_GTK && display_type != DT_SDL)) {
+        fprintf(stderr, "-no-quit is only valid for GTK and SDL, "
+                        "ignoring option\n");
+    }
+
 #if defined(CONFIG_GTK)
     if (display_type == DT_GTK) {
         early_gtk_display_init();
Signature · 1 line
1.7.10.4
#10 lore raw

[Qemu-devel] [PULL 25/26] cputlb: fix debug logs

In reply to Michael Tokarev

From: Hervé Poussineau <[email protected]>

'pd' variable has been removed in 06ef3525e1f271b6a842781a05eace5cf63b95c2.

---
 cputlb.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
cputlb.c +2 -2
index 86666c8..1230e9e 100644
@@ -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;
Signature · 1 line
1.7.10.4
#11 lore raw

[Qemu-devel] [PULL 13/26] device tree: Fix cppcheck warning

In reply to Michael Tokarev

From: Stefan Weil <[email protected]>

Fix this cppcheck warning:

Checking device_tree.c...
device_tree.c:216: style:
Checking if unsigned variable 'r' is less than zero.

---
 device_tree.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
device_tree.c +1 -1
index 56af24b..69be9da 100644
@@ -213,7 +213,7 @@ uint32_t qemu_devtree_get_phandle(void *fdt, const char *path)
     uint32_t r;
 
     r = fdt_get_phandle(fdt, findnode_nofail(fdt, path));
-    if (r <= 0) {
+    if (r == 0) {
         fprintf(stderr, "%s: Couldn't get phandle for %s: %s\n", __func__,
                 path, fdt_strerror(r));
         exit(1);
Signature · 1 line
1.7.10.4
#12 lore raw

[Qemu-devel] [PULL 06/26] curl: Whitespace only changes.

In reply to Michael Tokarev

From: "Richard W.M. Jones" <[email protected]>

Trivial patch to remove odd whitespace.

---
 block/curl.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
block/curl.c +2 -2
index b8935fd..4dc3b4b 100644
@@ -462,8 +462,8 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags)
     // initialize the multi interface!
 
     s->multi = curl_multi_init();
-    curl_multi_setopt( s->multi, CURLMOPT_SOCKETDATA, s); 
-    curl_multi_setopt( s->multi, CURLMOPT_SOCKETFUNCTION, curl_sock_cb ); 
+    curl_multi_setopt(s->multi, CURLMOPT_SOCKETDATA, s);
+    curl_multi_setopt(s->multi, CURLMOPT_SOCKETFUNCTION, curl_sock_cb);
     curl_multi_do(s);
 
     qemu_opts_del(opts);
Signature · 1 line
1.7.10.4
#13 lore raw

[Qemu-devel] [PULL 10/26] gtk: implement -full-screen

In reply to Michael Tokarev

From: Peter Wu <[email protected]>

Aiming for GTK as replacement for SDL, a feature like -full-screen should also be implemented.

Bringing the window into full-screen mode is done by activating the "Fullscreen" menu item. This is done after showing the windows to make the cursor and menu hidden.

v2: drop -no-frame implementation, use booleans instead of ints and ensure
consistency between ui state and menu.

---
 include/ui/console.h |    2 +-
 ui/gtk.c             |    6 +++++-
 vl.c                 |    2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)
include/ui/console.h +1 -1
index 4307b5f..f1d79f9 100644
@@ -339,6 +339,6 @@ int index_from_keycode(int code);
 
 /* gtk.c */
 void early_gtk_display_init(void);
-void gtk_display_init(DisplayState *ds);
+void gtk_display_init(DisplayState *ds, bool full_screen);
 
 #endif
ui/gtk.c +5 -1
index 63f6081..e314dba 100644
@@ -1435,7 +1435,7 @@ static const DisplayChangeListenerOps dcl_ops = {
     .dpy_cursor_define = gd_cursor_define,
 };
 
-void gtk_display_init(DisplayState *ds)
+void gtk_display_init(DisplayState *ds, bool full_screen)
 {
     GtkDisplayState *s = g_malloc0(sizeof(*s));
     char *filename;
@@ -1511,6 +1511,10 @@ void gtk_display_init(DisplayState *ds)
 
     gtk_widget_show_all(s->window);
 
+    if (full_screen) {
+        gtk_menu_item_activate(GTK_MENU_ITEM(s->full_screen_item));
+    }
+
     register_displaychangelistener(&s->dcl);
 
     global_state = s;
vl.c +1 -1
index 180fdde..169c807 100644
@@ -4348,7 +4348,7 @@ int main(int argc, char **argv, char **envp)
 #endif
 #if defined(CONFIG_GTK)
     case DT_GTK:
-        gtk_display_init(ds);
+        gtk_display_init(ds, full_screen);
         break;
 #endif
     default:
Signature · 1 line
1.7.10.4
#14 lore raw

[Qemu-devel] [PULL 14/26] hw/scsi: Don't increment a boolean value

In reply to Michael Tokarev

From: Stefan Weil <[email protected]>

This fixes a warning from cppcheck.

---
 hw/scsi/vmw_pvscsi.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/vmw_pvscsi.c +1 -1
index 48d12f4..446f723 100644
@@ -389,7 +389,7 @@ pvscsi_process_completion_queue(void *opaque)
         QTAILQ_REMOVE(&s->completion_queue, pvscsi_req, next);
         pvscsi_cmp_ring_put(s, &pvscsi_req->cmp);
         g_free(pvscsi_req);
-        has_completed++;
+        has_completed = true;
     }
 
     if (has_completed) {
Signature · 1 line
1.7.10.4
#15 lore raw

[Qemu-devel] [PULL 15/26] target-sparc: Replace free by g_free

In reply to Michael Tokarev

From: Stefan Weil <[email protected]>

The wrong function was reported by cppcheck.

---
 target-sparc/cpu.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target-sparc/cpu.c +1 -1
index 290b580..13bb7bb 100644
@@ -614,7 +614,7 @@ static int cpu_sparc_find_by_name(sparc_def_t *cpu_def, const char *cpu_model)
     return 0;
 
  error:
-    free(s);
+    g_free(s);
     return -1;
 }
 
Signature · 1 line
1.7.10.4
#16 lore raw

[Qemu-devel] [PULL 16/26] hw/xen: Use g_free instead of free and fix potential memory leaks

In reply to Michael Tokarev

From: Stefan Weil <[email protected]>

The wrong functions and the missing calls of g_free were reported by cppcheck.

---
 hw/xen/xen_pt_config_init.c |    4 ++--
 xen-all.c                   |    8 +++++---
 2 files changed, 7 insertions(+), 5 deletions(-)
hw/xen/xen_pt_config_init.c +2 -2
index 01872db..8ccc2e4 100644
@@ -1777,12 +1777,12 @@ static int xen_pt_config_reg_init(XenPCIPassthroughState *s,
         rc = reg->init(s, reg_entry->reg,
                        reg_grp->base_offset + reg->offset, &data);
         if (rc < 0) {
-            free(reg_entry);
+            g_free(reg_entry);
             return rc;
         }
         if (data == XEN_PT_INVALID_REG) {
             /* free unused BAR register entry */
-            free(reg_entry);
+            g_free(reg_entry);
             return 0;
         }
         /* set register value */
xen-all.c +5 -3
index bc105f1..1a1d7bb 100644
@@ -389,7 +389,7 @@ static int xen_remove_from_physmap(XenIOState *state,
     if (state->log_for_dirtybit == physmap) {
         state->log_for_dirtybit = NULL;
     }
-    free(physmap);
+    g_free(physmap);
 
     return 0;
 }
@@ -1030,7 +1030,7 @@ static void xen_read_physmap(XenIOState *state)
                 xen_domid, entries[i]);
         value = xs_read(state->xenstore, 0, path, &len);
         if (value == NULL) {
-            free(physmap);
+            g_free(physmap);
             continue;
         }
         physmap->start_addr = strtoull(value, NULL, 16);
@@ -1041,7 +1041,7 @@ static void xen_read_physmap(XenIOState *state)
                 xen_domid, entries[i]);
         value = xs_read(state->xenstore, 0, path, &len);
         if (value == NULL) {
-            free(physmap);
+            g_free(physmap);
             continue;
         }
         physmap->size = strtoull(value, NULL, 16);
@@ -1069,12 +1069,14 @@ int xen_hvm_init(void)
     state->xce_handle = xen_xc_evtchn_open(NULL, 0);
     if (state->xce_handle == XC_HANDLER_INITIAL_VALUE) {
         perror("xen: event channel open");
+        g_free(state);
         return -errno;
     }
 
     state->xenstore = xs_daemon_open();
     if (state->xenstore == NULL) {
         perror("xen: xenstore open");
+        g_free(state);
         return -errno;
     }
 
Signature · 1 line
1.7.10.4
#17 lore raw

[Qemu-devel] [PULL 23/26] main-loop: do not include slirp/slirp.h, use libslirp.h instead

In reply to Michael Tokarev

The header slirp/slirp.h is an internal header for slirp, and main-loop.c does not use internals from there. Instead, it uses public functions (slirp_update_timeout(), slirp_pollfds_fill() etc) which are declared in slirp/libslirp.h.

Including slirp/slirp.h is somewhat dangerous since it redefines errno on WIN32, so any file including it may misbehave wrt errno.

Unfortunately libslirp isn't self-contained, it needs declaration of struct in_addr, which is provided by qemu/sockets.h. Maybe instead of #including qemu/sockets.h before libslirp.h, it is better to make the latter self-contained.

---
 main-loop.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
main-loop.c +2 -1
index cf36645..a44fff6 100644
@@ -24,7 +24,8 @@
 
 #include "qemu-common.h"
 #include "qemu/timer.h"
-#include "slirp/slirp.h"
+#include "qemu/sockets.h"	// struct in_addr needed for libslirp.h
+#include "slirp/libslirp.h"
 #include "qemu/main-loop.h"
 #include "block/aio.h"
 
Signature · 1 line
1.7.10.4
#18 lore raw

[Qemu-devel] [PULL 24/26] create qemu_openpty_raw() helper function and move it to a separate file

In reply to Michael Tokarev

In two places qemu uses openpty() which is very system-dependent, and in both places the pty is switched to raw mode as well. Make a wrapper function which does both steps, and move all the system-dependent complexity into a separate file, together with static/local implementations of openpty() and cfmakeraw() from qemu-char.c.

It is in a separate file, not part of oslib-posix.c, because openpty() often resides in -lutil which is not linked to every program qemu builds.

This change removes #including of <pty.h>, <termios.h> and other rather specific system headers out of qemu-common.h, which isn't a place for such specific headers really.

This version has been verified to build correctly on Linux, OpenBSD, FreeBSD and OpenIndiana. On the latter it lets qemu to be built with gtk gui which were not possible there due to missing openpty() and cfmakeraw().

---
 include/qemu-common.h |   15 +-----
 qemu-char.c           |   77 ++--------------------------
 ui/gtk.c              |   12 ++---
 util/Makefile.objs    |    2 +-
 util/qemu-openpty.c   |  135 +++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 146 insertions(+), 95 deletions(-)
 create mode 100644 util/qemu-openpty.c
include/qemu-common.h +2 -13
index ed8b6e2..3c91375 100644
@@ -42,19 +42,6 @@
 #include <signal.h>
 #include "glib-compat.h"
 
-#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
-#  include <util.h>
-# endif
-#elif defined CONFIG_SOLARIS
-# include <stropts.h>
-#endif
-
 #ifdef _WIN32
 #include "sysemu/os-win32.h"
 #endif
@@ -235,6 +222,8 @@ ssize_t qemu_recv_full(int fd, void *buf, size_t count, int flags)
 
 #ifndef _WIN32
 int qemu_pipe(int pipefd[2]);
+/* like openpty() but also makes it raw; return master fd */
+int qemu_openpty_raw(int *aslave, char *pty_name);
 #endif
 
 #ifdef _WIN32
qemu-char.c +5 -72

102 lines not on this page · raw message

ui/gtk.c +3 -9
index e314dba..50a6993 100644
@@ -1160,8 +1160,7 @@ static GSList *gd_vc_init(GtkDisplayState *s, VirtualConsole *vc, int index, GSL
     GIOChannel *chan;
     GtkWidget *scrolled_window;
     GtkAdjustment *vadjustment;
-    int master_fd, slave_fd, ret;
-    struct termios tty;
+    int master_fd, slave_fd;
 
     snprintf(buffer, sizeof(buffer), "vc%d", index);
     snprintf(path, sizeof(path), "<QEMU>/View/VC%d", index);
@@ -1181,13 +1180,8 @@ static GSList *gd_vc_init(GtkDisplayState *s, VirtualConsole *vc, int index, GSL
 
     vc->terminal = vte_terminal_new();
 
-    ret = openpty(&master_fd, &slave_fd, NULL, NULL, NULL);
-    g_assert(ret != -1);
-
-    /* Set raw attributes on the pty. */
-    tcgetattr(slave_fd, &tty);
-    cfmakeraw(&tty);
-    tcsetattr(slave_fd, TCSAFLUSH, &tty);
+    master_fd = qemu_openpty_raw(&slave_fd, NULL);
+    g_assert(master_fd != -1);
 
 #if VTE_CHECK_VERSION(0, 26, 0)
     pty = vte_pty_new_foreign(master_fd, NULL);
util/Makefile.objs +1 -1
index 4a1bd4e..dc72ab0 100644
@@ -1,6 +1,6 @@
 util-obj-y = osdep.o cutils.o unicode.o qemu-timer-common.o
 util-obj-$(CONFIG_WIN32) += oslib-win32.o qemu-thread-win32.o event_notifier-win32.o
-util-obj-$(CONFIG_POSIX) += oslib-posix.o qemu-thread-posix.o event_notifier-posix.o
+util-obj-$(CONFIG_POSIX) += oslib-posix.o qemu-thread-posix.o event_notifier-posix.o qemu-openpty.o
 util-obj-y += envlist.o path.o host-utils.o cache-utils.o module.o
 util-obj-y += bitmap.o bitops.o hbitmap.o
 util-obj-y += fifo8.o
util/qemu-openpty.c new file +135 -0

135 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#19 lore raw

[Qemu-devel] [PULL 17/26] ivshmem: add missing error exit(2)

In reply to Michael Tokarev

From: Stefan Hajnoczi <[email protected]>

If the user fails to specify 'chardev' or 'shm' then we cannot continue. Exit right away so that we don't invoke shm_open(3) with a NULL pointer.

It would be nice to replace exit(1) with error returns in the PCI device .init() function, but leave that for another patch since exit(1) is currently used elsewhere.

Spotted by Coverity.

---
 hw/misc/ivshmem.c |    1 +
 1 file changed, 1 insertion(+)
hw/misc/ivshmem.c +1 -0
index a19a6d6..5658f73 100644
@@ -735,6 +735,7 @@ static int pci_ivshmem_init(PCIDevice *dev)
 
         if (s->shmobj == NULL) {
             fprintf(stderr, "Must specify 'chardev' or 'shm' to ivshmem\n");
+            exit(1);
         }
 
         IVSHMEM_DPRINTF("using shm_open (shm object = %s)\n", s->shmobj);
Signature · 1 line
1.7.10.4
#20 lore raw

[Qemu-devel] [PULL 09/26] char/serial: serial_ioport_write: Factor out common code

In reply to Michael Tokarev

From: Peter Crosthwaite <[email protected]>

These three lines are common to both FIFO and regular mode. Just factor them out to outside the if rather than replicate the same lines inside both if and else.

---
 hw/char/serial.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
hw/char/serial.c +3 -7
index 0a2b6c9..017610e 100644
@@ -285,15 +285,11 @@ static void serial_ioport_write(void *opaque, hwaddr addr, uint64_t val,
                     fifo8_pop(&s->xmit_fifo);
                 }
                 fifo8_push(&s->xmit_fifo, s->thr);
-                s->thr_ipending = 0;
                 s->lsr &= ~UART_LSR_TEMT;
-                s->lsr &= ~UART_LSR_THRE;
-                serial_update_irq(s);
-            } else {
-                s->thr_ipending = 0;
-                s->lsr &= ~UART_LSR_THRE;
-                serial_update_irq(s);
             }
+            s->thr_ipending = 0;
+            s->lsr &= ~UART_LSR_THRE;
+            serial_update_irq(s);
             serial_xmit(NULL, G_IO_OUT, s);
         }
         break;
Signature · 1 line
1.7.10.4
#21 lore raw

[Qemu-devel] [PULL 20/26] KVM: PPC: Add dummy kvm_arch_init_irq_routing()

In reply to Michael Tokarev

From: Scott Wood <[email protected]>

The common KVM code insists on calling kvm_arch_init_irq_routing() as soon as it sees kernel header support for it (regardless of whether QEMU supports it). Provide a dummy function to satisfy this.

Unlike x86, PPC does not have one default irqchip, so there's no common code that we'd stick here. Even if you ignore the routes themselves, which even on x86 are not set up in this function, the initial XICS kernel implementation will not support IRQ routing, so it's best to leave even the general feature flags up to the specific irqchip code.

---
 target-ppc/kvm.c |    4 ++++
 1 file changed, 4 insertions(+)
target-ppc/kvm.c +4 -0
index 3ab2946..2bbc3b8 100644
@@ -1797,3 +1797,7 @@ int kvm_arch_on_sigbus(int code, void *addr)
 {
     return 1;
 }
+
+void kvm_arch_init_irq_routing(KVMState *s)
+{
+}
Signature · 1 line
1.7.10.4
#22 lore raw

[Qemu-devel] [PULL 26/26] piix: fix some printf errors when debug is enabled

In reply to Michael Tokarev

From: Hu Tao <[email protected]>

And use PRIxxx macros if possible.

---
 hw/acpi/piix4.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
hw/acpi/piix4.c +6 -6
index e6525ac..756df3b 100644
@@ -518,7 +518,7 @@ static uint64_t gpe_readb(void *opaque, hwaddr addr, unsigned width)
     PIIX4PMState *s = opaque;
     uint32_t val = acpi_gpe_ioport_readb(&s->ar, addr);
 
-    PIIX4_DPRINTF("gpe read %x == %x\n", addr, val);
+    PIIX4_DPRINTF("gpe read %" HWADDR_PRIx " == %" PRIu32 "\n", addr, val);
     return val;
 }
 
@@ -530,7 +530,7 @@ static void gpe_writeb(void *opaque, hwaddr addr, uint64_t val,
     acpi_gpe_ioport_writeb(&s->ar, addr, val);
     pm_update_sci(s);
 
-    PIIX4_DPRINTF("gpe write %x <== %d\n", addr, val);
+    PIIX4_DPRINTF("gpe write %" HWADDR_PRIx " <== %" PRIu64 "\n", addr, val);
 }
 
 static const MemoryRegionOps piix4_gpe_ops = {
@@ -553,15 +553,15 @@ static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size)
         /* Manufacture an "up" value to cause a device check on any hotplug
          * slot with a device.  Extra device checks are harmless. */
         val = s->pci0_slot_device_present & s->pci0_hotplug_enable;
-        PIIX4_DPRINTF("pci_up_read %x\n", val);
+        PIIX4_DPRINTF("pci_up_read %" PRIu32 "\n", val);
         break;
     case PCI_DOWN_BASE - PCI_HOTPLUG_ADDR:
         val = s->pci0_status.down;
-        PIIX4_DPRINTF("pci_down_read %x\n", val);
+        PIIX4_DPRINTF("pci_down_read %" PRIu32 "\n", val);
         break;
     case PCI_EJ_BASE - PCI_HOTPLUG_ADDR:
         /* No feature defined yet */
-        PIIX4_DPRINTF("pci_features_read %x\n", val);
+        PIIX4_DPRINTF("pci_features_read %" PRIu32 "\n", val);
         break;
     case PCI_RMV_BASE - PCI_HOTPLUG_ADDR:
         val = s->pci0_hotplug_enable;
@@ -579,7 +579,7 @@ static void pci_write(void *opaque, hwaddr addr, uint64_t data,
     switch (addr) {
     case PCI_EJ_BASE - PCI_HOTPLUG_ADDR:
         acpi_piix_eject_slot(opaque, (uint32_t)data);
-        PIIX4_DPRINTF("pciej write %" HWADDR_PRIx " <== % " PRIu64 "\n",
+        PIIX4_DPRINTF("pciej write %" HWADDR_PRIx " <== %" PRIu64 "\n",
                       addr, data);
         break;
     default:
Signature · 1 line
1.7.10.4
#23 lore raw

[Qemu-devel] [PULL 07/26] char/serial: cosmetic fixes.

In reply to Michael Tokarev

From: Peter Crosthwaite <[email protected]>

Some cosmetic fixes to char/serial fixing some checkpatch errors.

---
 hw/char/serial.c |   30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)
hw/char/serial.c +19 -11
index 66b6348..bd6813e 100644
@@ -263,8 +263,9 @@ static gboolean serial_xmit(GIOChannel *chan, GIOCondition cond, void *opaque)
     if (s->tsr_retry <= 0) {
         if (s->fcr & UART_FCR_FE) {
             s->tsr = fifo_get(s,XMIT_FIFO);
-            if (!s->xmit_fifo.count)
+            if (!s->xmit_fifo.count) {
                 s->lsr |= UART_LSR_THRE;
+            }
         } else if ((s->lsr & UART_LSR_THRE)) {
             return FALSE;
         } else {
@@ -461,10 +462,11 @@ static uint64_t serial_ioport_read(void *opaque, hwaddr addr, unsigned size)
         } else {
             if(s->fcr & UART_FCR_FE) {
                 ret = fifo_get(s,RECV_FIFO);
-                if (s->recv_fifo.count == 0)
+                if (s->recv_fifo.count == 0) {
                     s->lsr &= ~(UART_LSR_DR | UART_LSR_BI);
-                else
+                } else {
                     qemu_mod_timer(s->fifo_timeout_timer, qemu_get_clock_ns (vm_clock) + s->char_transmit_time * 4);
+                }
                 s->timeout_ipending = 0;
             } else {
                 ret = s->rbr;
@@ -534,15 +536,21 @@ static uint64_t serial_ioport_read(void *opaque, hwaddr addr, unsigned size)
 static int serial_can_receive(SerialState *s)
 {
     if(s->fcr & UART_FCR_FE) {
-        if(s->recv_fifo.count < UART_FIFO_LENGTH)
-        /* Advertise (fifo.itl - fifo.count) bytes when count < ITL, and 1 if above. If UART_FIFO_LENGTH - fifo.count is
-        advertised the effect will be to almost always fill the fifo completely before the guest has a chance to respond,
-        effectively overriding the ITL that the guest has set. */
-             return (s->recv_fifo.count <= s->recv_fifo.itl) ? s->recv_fifo.itl - s->recv_fifo.count : 1;
-        else
-             return 0;
+        if (s->recv_fifo.count < UART_FIFO_LENGTH) {
+            /*
+             * Advertise (fifo.itl - fifo.count) bytes when count < ITL, and 1
+             * if above. If UART_FIFO_LENGTH - fifo.count is advertised the
+             * effect will be to almost always fill the fifo completely before
+             * the guest has a chance to respond, effectively overriding the ITL
+             * that the guest has set.
+             */
+            return (s->recv_fifo.count <= s->recv_fifo.itl) ?
+                        s->recv_fifo.itl - s->recv_fifo.count : 1;
+        } else {
+            return 0;
+        }
     } else {
-    return !(s->lsr & UART_LSR_DR);
+        return !(s->lsr & UART_LSR_DR);
     }
 }
 
Signature · 1 line
1.7.10.4
#24 lore raw

[Qemu-devel] [PULL 08/26] char/serial: Use generic Fifo8

In reply to Michael Tokarev

From: Peter Crosthwaite <[email protected]>

Use the generic Fifo8 helper provided by QEMU, rather than re-implement privately.

---
 hw/char/serial.c         |   98 ++++++++++++++++------------------------------
 include/hw/char/serial.h |   15 +++----
 2 files changed, 39 insertions(+), 74 deletions(-)
hw/char/serial.c +34 -64
index bd6813e..0a2b6c9 100644
@@ -92,8 +92,6 @@
 #define UART_FCR_RFR        0x02    /* RCVR Fifo Reset */
 #define UART_FCR_FE         0x01    /* FIFO Enable */
 
-#define XMIT_FIFO           0
-#define RECV_FIFO           1
 #define MAX_XMIT_RETRY      4
 
 #ifdef DEBUG_SERIAL
@@ -106,50 +104,14 @@ do {} while (0)
 
 static void serial_receive1(void *opaque, const uint8_t *buf, int size);
 
-static void fifo_clear(SerialState *s, int fifo)
+static inline void recv_fifo_put(SerialState *s, uint8_t chr)
 {
-    SerialFIFO *f = (fifo) ? &s->recv_fifo : &s->xmit_fifo;
-    memset(f->data, 0, UART_FIFO_LENGTH);
-    f->count = 0;
-    f->head = 0;
-    f->tail = 0;
-}
-
-static int fifo_put(SerialState *s, int fifo, uint8_t chr)
-{
-    SerialFIFO *f = (fifo) ? &s->recv_fifo : &s->xmit_fifo;
-
     /* Receive overruns do not overwrite FIFO contents. */
-    if (fifo == XMIT_FIFO || f->count < UART_FIFO_LENGTH) {
-
-        f->data[f->head++] = chr;
-
-        if (f->head == UART_FIFO_LENGTH)
-            f->head = 0;
-    }
-
-    if (f->count < UART_FIFO_LENGTH)
-        f->count++;
-    else if (fifo == RECV_FIFO)
+    if (!fifo8_is_full(&s->recv_fifo)) {
+        fifo8_push(&s->recv_fifo, chr);
+    } else {
         s->lsr |= UART_LSR_OE;
-
-    return 1;
-}
-
-static uint8_t fifo_get(SerialState *s, int fifo)
-{
-    SerialFIFO *f = (fifo) ? &s->recv_fifo : &s->xmit_fifo;
-    uint8_t c;
-
-    if(f->count == 0)
-        return 0;
-
-    c = f->data[f->tail++];
-    if (f->tail == UART_FIFO_LENGTH)
-        f->tail = 0;
-    f->count--;
-
-    return c;
+    }
 }
 
 static void serial_update_irq(SerialState *s)
@@ -165,7 +127,7 @@ static void serial_update_irq(SerialState *s)
         tmp_iir = UART_IIR_CTI;
     } else if ((s->ier & UART_IER_RDI) && (s->lsr & UART_LSR_DR) &&
                (!(s->fcr & UART_FCR_FE) ||
-                s->recv_fifo.count >= s->recv_fifo.itl)) {
+                s->recv_fifo.num >= s->recv_fifo_itl)) {
         tmp_iir = UART_IIR_RDI;
     } else if ((s->ier & UART_IER_THRI) && s->thr_ipending) {
         tmp_iir = UART_IIR_THRI;
@@ -262,8 +224,9 @@ static gboolean serial_xmit(GIOChannel *chan, GIOCondition cond, void *opaque)
 
     if (s->tsr_retry <= 0) {
         if (s->fcr & UART_FCR_FE) {
-            s->tsr = fifo_get(s,XMIT_FIFO);
-            if (!s->xmit_fifo.count) {
+            s->tsr = fifo8_is_full(&s->xmit_fifo) ?
+                        0 : fifo8_pop(&s->xmit_fifo);
+            if (!s->xmit_fifo.num) {
                 s->lsr |= UART_LSR_THRE;
             }
         } else if ((s->lsr & UART_LSR_THRE)) {
@@ -317,7 +280,11 @@ static void serial_ioport_write(void *opaque, hwaddr addr, uint64_t val,
         } else {
             s->thr = (uint8_t) val;
             if(s->fcr & UART_FCR_FE) {
-                fifo_put(s, XMIT_FIFO, s->thr);
+                /* xmit overruns overwrite data, so make space if needed */
+                if (fifo8_is_full(&s->xmit_fifo)) {
+                    fifo8_pop(&s->xmit_fifo);
+                }
+                fifo8_push(&s->xmit_fifo, s->thr);
                 s->thr_ipending = 0;
                 s->lsr &= ~UART_LSR_TEMT;
                 s->lsr &= ~UART_LSR_THRE;
@@ -368,28 +335,28 @@ static void serial_ioport_write(void *opaque, hwaddr addr, uint64_t val,
         if (val & UART_FCR_RFR) {
             qemu_del_timer(s->fifo_timeout_timer);
             s->timeout_ipending=0;
-            fifo_clear(s,RECV_FIFO);
+            fifo8_reset(&s->recv_fifo);
         }
 
         if (val & UART_FCR_XFR) {
-            fifo_clear(s,XMIT_FIFO);
+            fifo8_reset(&s->xmit_fifo);
         }
 
         if (val & UART_FCR_FE) {
             s->iir |= UART_IIR_FE;
-            /* Set RECV_FIFO trigger Level */
+            /* Set recv_fifo trigger Level */
             switch (val & 0xC0) {
             case UART_FCR_ITL_1:
-                s->recv_fifo.itl = 1;
+                s->recv_fifo_itl = 1;
                 break;
             case UART_FCR_ITL_2:
-                s->recv_fifo.itl = 4;
+                s->recv_fifo_itl = 4;
                 break;
             case UART_FCR_ITL_3:
-                s->recv_fifo.itl = 8;
+                s->recv_fifo_itl = 8;
                 break;
             case UART_FCR_ITL_4:
-                s->recv_fifo.itl = 14;
+                s->recv_fifo_itl = 14;
                 break;
             }
         } else
@@ -461,8 +428,9 @@ static uint64_t serial_ioport_read(void *opaque, hwaddr addr, unsigned size)
             ret = s->divider & 0xff;
         } else {
             if(s->fcr & UART_FCR_FE) {
-                ret = fifo_get(s,RECV_FIFO);
-                if (s->recv_fifo.count == 0) {
+                ret = fifo8_is_full(&s->recv_fifo) ?
+                            0 : fifo8_pop(&s->recv_fifo);
+                if (s->recv_fifo.num == 0) {
                     s->lsr &= ~(UART_LSR_DR | UART_LSR_BI);
                 } else {
                     qemu_mod_timer(s->fifo_timeout_timer, qemu_get_clock_ns (vm_clock) + s->char_transmit_time * 4);
@@ -536,7 +504,7 @@ static uint64_t serial_ioport_read(void *opaque, hwaddr addr, unsigned size)
 static int serial_can_receive(SerialState *s)
 {
     if(s->fcr & UART_FCR_FE) {
-        if (s->recv_fifo.count < UART_FIFO_LENGTH) {
+        if (s->recv_fifo.num < UART_FIFO_LENGTH) {
             /*
              * Advertise (fifo.itl - fifo.count) bytes when count < ITL, and 1
              * if above. If UART_FIFO_LENGTH - fifo.count is advertised the
@@ -544,8 +512,8 @@ static int serial_can_receive(SerialState *s)
              * the guest has a chance to respond, effectively overriding the ITL
              * that the guest has set.
              */
-            return (s->recv_fifo.count <= s->recv_fifo.itl) ?
-                        s->recv_fifo.itl - s->recv_fifo.count : 1;
+            return (s->recv_fifo.num <= s->recv_fifo_itl) ?
+                        s->recv_fifo_itl - s->recv_fifo.num : 1;
         } else {
             return 0;
         }
@@ -558,7 +526,7 @@ static void serial_receive_break(SerialState *s)
 {
     s->rbr = 0;
     /* When the LSR_DR is set a null byte is pushed into the fifo */
-    fifo_put(s, RECV_FIFO, '\0');
+    recv_fifo_put(s, '\0');
     s->lsr |= UART_LSR_BI | UART_LSR_DR;
     serial_update_irq(s);
 }
@@ -566,7 +534,7 @@ static void serial_receive_break(SerialState *s)
 /* There's data in recv_fifo and s->rbr has not been read for 4 char transmit times */
 static void fifo_timeout_int (void *opaque) {
     SerialState *s = opaque;
-    if (s->recv_fifo.count) {
+    if (s->recv_fifo.num) {
         s->timeout_ipending = 1;
         serial_update_irq(s);
     }
@@ -588,7 +556,7 @@ static void serial_receive1(void *opaque, const uint8_t *buf, int size)
     if(s->fcr & UART_FCR_FE) {
         int i;
         for (i = 0; i < size; i++) {
-            fifo_put(s, RECV_FIFO, buf[i]);
+            recv_fifo_put(s, buf[i]);
         }
         s->lsr |= UART_LSR_DR;
         /* call the timeout receive callback in 4 char transmit time */
@@ -668,8 +636,8 @@ static void serial_reset(void *opaque)
     s->char_transmit_time = (get_ticks_per_sec() / 9600) * 10;
     s->poll_msl = 0;
 
-    fifo_clear(s,RECV_FIFO);
-    fifo_clear(s,XMIT_FIFO);
+    fifo8_reset(&s->recv_fifo);
+    fifo8_reset(&s->xmit_fifo);
 
     s->last_xmit_ts = qemu_get_clock_ns(vm_clock);
 
@@ -692,6 +660,8 @@ void serial_init_core(SerialState *s)
 
     qemu_chr_add_handlers(s->chr, serial_can_receive1, serial_receive1,
                           serial_event, s);
+    fifo8_create(&s->recv_fifo, UART_FIFO_LENGTH);
+    fifo8_create(&s->xmit_fifo, UART_FIFO_LENGTH);
 }
 
 void serial_exit_core(SerialState *s)
include/hw/char/serial.h +5 -10
index bca79f1..9ab81f6 100644
@@ -28,17 +28,10 @@
 #include "hw/hw.h"
 #include "sysemu/sysemu.h"
 #include "exec/memory.h"
+#include "qemu/fifo8.h"
 
 #define UART_FIFO_LENGTH    16      /* 16550A Fifo Length */
 
-typedef struct SerialFIFO {
-    uint8_t data[UART_FIFO_LENGTH];
-    uint8_t count;
-    uint8_t itl;                        /* Interrupt Trigger Level */
-    uint8_t tail;
-    uint8_t head;
-} SerialFIFO;
-
 struct SerialState {
     uint16_t divider;
     uint8_t rbr; /* receive register */
@@ -67,8 +60,10 @@ struct SerialState {
 
     /* Time when the last byte was successfully sent out of the tsr */
     uint64_t last_xmit_ts;
-    SerialFIFO recv_fifo;
-    SerialFIFO xmit_fifo;
+    Fifo8 recv_fifo;
+    Fifo8 xmit_fifo;
+    /* Interrupt trigger level for recv_fifo */
+    uint8_t recv_fifo_itl;
 
     struct QEMUTimer *fifo_timeout_timer;
     int timeout_ipending;           /* timeout interrupt pending state */
Signature · 1 line
1.7.10.4
#25 lore raw

[Qemu-devel] [PULL 18/26] KVM: ARM: Add dummy kvm_arch_init_irq_routing()

In reply to Michael Tokarev

From: Alexey Kardashevskiy <[email protected]>

The common KVM code insists on calling kvm_arch_init_irq_routing() as soon as it sees kernel header support for it (regardless of whether QEMU supports it). Provide a dummy function to satisfy this.

---
 target-arm/kvm.c |    4 ++++
 1 file changed, 4 insertions(+)
target-arm/kvm.c +4 -0
index b7bdc03..27dcab9 100644
@@ -491,3 +491,7 @@ void kvm_arch_remove_all_hw_breakpoints(void)
 {
     qemu_log_mask(LOG_UNIMP, "%s: not implemented\n", __func__);
 }
+
+void kvm_arch_init_irq_routing(KVMState *s)
+{
+}
Signature · 1 line
1.7.10.4
#26 lore raw

[Qemu-devel] [PULL 22/26] libcacard/vscclient: fix leakage of socket on error paths

In reply to Michael Tokarev

From: Alon Levy <[email protected]>

Spotted by Coverity.

---
 libcacard/vscclient.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
libcacard/vscclient.c +7 -2
index ac23647..5180d29 100644
@@ -618,18 +618,22 @@ connect_to_qemu(
     if (ret != 0) {
         /* Error */
         fprintf(stderr, "getaddrinfo failed\n");
-        return -1;
+        goto cleanup_socket;
     }
 
     if (connect(sock, server->ai_addr, server->ai_addrlen) < 0) {
         /* Error */
         fprintf(stderr, "Could not connect\n");
-        return -1;
+        goto cleanup_socket;
     }
     if (verbose) {
         printf("Connected (sizeof Header=%zd)!\n", sizeof(VSCMsgHeader));
     }
     return sock;
+
+cleanup_socket:
+    closesocket(sock);
+    return -1;
 }
 
 int
@@ -759,5 +763,6 @@ main(
     g_io_channel_unref(channel_socket);
     g_byte_array_unref(socket_to_send);
 
+    closesocket(sock);
     return 0;
 }
Signature · 1 line
1.7.10.4
#27 lore raw

[Qemu-devel] [PULL 21/26] linux-headers: Update to v3.10-rc5

In reply to Michael Tokarev

From: Alexey Kardashevskiy <[email protected]>

This adds symbols required for PPC64 pseries platform features:
1. sPAPR live migration;
2. in-kernel XICS interrupt controller.

---
 linux-headers/asm-arm/kvm.h       |   12 ++--
 linux-headers/asm-mips/kvm.h      |  138 +++++++++++++++++++++++++++++++++++++
 linux-headers/asm-mips/kvm_para.h |    1 +
 linux-headers/asm-powerpc/kvm.h   |   89 ++++++++++++++++++++++++
 linux-headers/asm-x86/kvm.h       |    1 -
 linux-headers/linux/kvm.h         |   42 +++++++++--
 linux-headers/linux/vfio.h        |    1 +
 linux-headers/linux/vhost.h       |   28 ++++++++
 8 files changed, 299 insertions(+), 13 deletions(-)
 create mode 100644 linux-headers/asm-mips/kvm.h
 create mode 100644 linux-headers/asm-mips/kvm_para.h
linux-headers/asm-arm/kvm.h +6 -6
index 023bfeb..c1ee007 100644
@@ -53,12 +53,12 @@
 #define KVM_ARM_FIQ_spsr	fiq_regs[7]
 
 struct kvm_regs {
-	struct pt_regs usr_regs;/* R0_usr - R14_usr, PC, CPSR */
-	__u32 svc_regs[3];	/* SP_svc, LR_svc, SPSR_svc */
-	__u32 abt_regs[3];	/* SP_abt, LR_abt, SPSR_abt */
-	__u32 und_regs[3];	/* SP_und, LR_und, SPSR_und */
-	__u32 irq_regs[3];	/* SP_irq, LR_irq, SPSR_irq */
-	__u32 fiq_regs[8];	/* R8_fiq - R14_fiq, SPSR_fiq */
+	struct pt_regs usr_regs;	/* R0_usr - R14_usr, PC, CPSR */
+	unsigned long svc_regs[3];	/* SP_svc, LR_svc, SPSR_svc */
+	unsigned long abt_regs[3];	/* SP_abt, LR_abt, SPSR_abt */
+	unsigned long und_regs[3];	/* SP_und, LR_und, SPSR_und */
+	unsigned long irq_regs[3];	/* SP_irq, LR_irq, SPSR_irq */
+	unsigned long fiq_regs[8];	/* R8_fiq - R14_fiq, SPSR_fiq */
 };
 
 /* Supported Processor Types */
linux-headers/asm-mips/kvm.h new file +138 -0

138 lines not on this page · raw message

linux-headers/asm-mips/kvm_para.h new file +1 -0
new file mode 100644
index 0000000..14fab8f
@@ -0,0 +1 @@
+#include <asm-generic/kvm_para.h>
linux-headers/asm-powerpc/kvm.h +89 -0

119 lines not on this page · raw message

linux-headers/asm-x86/kvm.h +0 -1
index a65ec29..5d9a303 100644
@@ -29,7 +29,6 @@
 #define __KVM_HAVE_PIT
 #define __KVM_HAVE_IOAPIC
 #define __KVM_HAVE_IRQ_LINE
-#define __KVM_HAVE_DEVICE_ASSIGNMENT
 #define __KVM_HAVE_MSI
 #define __KVM_HAVE_USER_NMI
 #define __KVM_HAVE_GUEST_DEBUG
linux-headers/linux/kvm.h +36 -6

76 lines not on this page · raw message

linux-headers/linux/vfio.h +1 -0
index e094121..7ec1864 100644
@@ -319,6 +319,7 @@ enum {
 	VFIO_PCI_INTX_IRQ_INDEX,
 	VFIO_PCI_MSI_IRQ_INDEX,
 	VFIO_PCI_MSIX_IRQ_INDEX,
+	VFIO_PCI_ERR_IRQ_INDEX,
 	VFIO_PCI_NUM_IRQS
 };
 
linux-headers/linux/vhost.h +28 -0
index 165a484..c656f61 100644
@@ -127,4 +127,32 @@ struct vhost_memory {
 /* vhost-net should add virtio_net_hdr for RX, and strip for TX packets. */
 #define VHOST_NET_F_VIRTIO_NET_HDR 27
 
+/* VHOST_SCSI specific definitions */
+
+/*
+ * Used by QEMU userspace to ensure a consistent vhost-scsi ABI.
+ *
+ * ABI Rev 0: July 2012 version starting point for v3.6-rc merge candidate +
+ *            RFC-v2 vhost-scsi userspace.  Add GET_ABI_VERSION ioctl usage
+ * ABI Rev 1: January 2013. Ignore vhost_tpgt filed in struct vhost_scsi_target.
+ *            All the targets under vhost_wwpn can be seen and used by guset.
+ */
+
+#define VHOST_SCSI_ABI_VERSION	1
+
+struct vhost_scsi_target {
+	int abi_version;
+	char vhost_wwpn[224]; /* TRANSPORT_IQN_LEN */
+	unsigned short vhost_tpgt;
+	unsigned short reserved;
+};
+
+#define VHOST_SCSI_SET_ENDPOINT _IOW(VHOST_VIRTIO, 0x40, struct vhost_scsi_target)
+#define VHOST_SCSI_CLEAR_ENDPOINT _IOW(VHOST_VIRTIO, 0x41, struct vhost_scsi_target)
+/* Changing this breaks userspace. */
+#define VHOST_SCSI_GET_ABI_VERSION _IOW(VHOST_VIRTIO, 0x42, int)
+/* Set and get the events missed flag */
+#define VHOST_SCSI_SET_EVENTS_MISSED _IOW(VHOST_VIRTIO, 0x43, __u32)
+#define VHOST_SCSI_GET_EVENTS_MISSED _IOW(VHOST_VIRTIO, 0x44, __u32)
+
 #endif
Signature · 1 line
1.7.10.4