]> xenbits.xensource.com Git - qemu-xen-4.2-testing.git/commitdiff
Fixes to source files to compile as a stubdomain
authorIan Jackson <ian.jackson@eu.citrix.com>
Thu, 11 Sep 2008 15:51:06 +0000 (16:51 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Thu, 11 Sep 2008 15:51:06 +0000 (16:51 +0100)
Various fixes to some source files to compile as a stubdomain.

(Most of these changes were originally written by Samuel for an older
 version of qemu-remote.  Patch to exec-all.h dropped in this checkin
 by iwj.)

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
block-vbd.c
hw/scsi-disk.c
hw/vga.c
i386-dm/exec-dm.c
vl.c
xen-vl-extra.c
xenfbfront.c
xenstore.c

index 10f7a21f5388652ed875822292b9d9950dd6fd6f..9c74952d10d66258351f2f85a051421246b7487f 100644 (file)
@@ -22,7 +22,8 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
-#include "vl.h"
+#include "qemu-common.h"
+#include "audio/sys-queue.h"
 #include "block_int.h"
 #include <assert.h>
 #include <xenbus.h>
index 3f781666380f8d598e09feaa34b93366682e1c85..e3d8069be3225e5809ee3148ff9f65243da7abfd 100644 (file)
@@ -36,7 +36,7 @@ do { fprintf(stderr, "scsi-disk: " fmt , ##args); } while (0)
 
 #ifdef CONFIG_STUBDOM
 #include <xen/io/blkif.h>
-#define SCSI_DMA_BUF_SIZE    (BLKIF_MAX_SEGMENTS_PER_REQUEST * TARGET_PAGE_SIZE)
+#define SCSI_DMA_BUF_SIZE    ((BLKIF_MAX_SEGMENTS_PER_REQUEST - 1) * PAGE_SIZE)
 #else
 #define SCSI_DMA_BUF_SIZE    131072
 #endif
index 9e0dea8211b81f890c2b449054478ec8a2a4a84c..65c710a153f31092b9a7bd69c9f2f938c6b75c6a 100644 (file)
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -27,6 +27,9 @@
 #include "pci.h"
 #include "vga_int.h"
 #include <sys/mman.h>
+#include "sysemu.h"
+#include "qemu-xen.h"
+#include "exec-all.h"
 
 //#define DEBUG_VGA
 //#define DEBUG_VGA_MEM
index d511021c418c78fdeb3df9dba11aa2a1fd53d295..dec4aa8b28e25e59babc99b9ea1a55e86383117d 100644 (file)
@@ -574,8 +574,8 @@ void cpu_physical_memory_rw(target_phys_addr_t _addr, uint8_t *buf,
 #ifdef CONFIG_STUBDOM
     if (logdirty_bitmap != NULL)
         xc_hvm_modified_memory(xc_handle, domid, _addr >> TARGET_PAGE_BITS,
-                (_addr + _len + TARGET_PAGE_SIZE - 1) >> TARGET_PAGE_BITS
-                    - _addr >> TARGET_PAGE_BITS);
+                ((_addr + _len + TARGET_PAGE_SIZE - 1) >> TARGET_PAGE_BITS)
+                    - (_addr >> TARGET_PAGE_BITS));
 #endif
 
     mapcache_unlock();
diff --git a/vl.c b/vl.c
index 3f14553ba4e06b4473c5cbd8908f945e4249a8cb..e215af70969945832e2b0043bbdd61388086f580 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -38,6 +38,7 @@
 #include "qemu-char.h"
 #include "block.h"
 #include "audio/audio.h"
+#include "qemu-xen.h"
 
 #include <unistd.h>
 #include <stdlib.h>
@@ -114,6 +115,7 @@ int inet_aton(const char *cp, struct in_addr *ia);
 #include <mmsystem.h>
 #define getopt_long_only getopt_long
 #define memalign(align, size) malloc(size)
+#define NO_UNIX_SOCKETS 1
 #endif
 
 #include "qemu_socket.h"
@@ -3104,7 +3106,7 @@ static void udp_chr_update_read_handler(CharDriverState *chr)
 }
 
 int parse_host_port(struct sockaddr_in *saddr, const char *str);
-#ifndef _WIN32
+#ifndef NO_UNIX_SOCKETS
 static int parse_unix_path(struct sockaddr_un *uaddr, const char *str);
 #endif
 int parse_host_src_port(struct sockaddr_in *haddr,
@@ -3312,7 +3314,7 @@ static void tcp_chr_accept(void *opaque)
     CharDriverState *chr = opaque;
     TCPCharDriver *s = chr->opaque;
     struct sockaddr_in saddr;
-#ifndef _WIN32
+#ifndef NO_UNIX_SOCKETS
     struct sockaddr_un uaddr;
 #endif
     struct sockaddr *addr;
@@ -3320,7 +3322,7 @@ static void tcp_chr_accept(void *opaque)
     int fd;
 
     for(;;) {
-#ifndef _WIN32
+#ifndef NO_UNIX_SOCKETS
        if (s->is_unix) {
            len = sizeof(uaddr);
            addr = (struct sockaddr *)&uaddr;
@@ -3369,13 +3371,13 @@ static CharDriverState *qemu_chr_open_tcp(const char *host_str,
     int do_nodelay = 0;
     const char *ptr;
     struct sockaddr_in saddr;
-#ifndef _WIN32
+#ifndef NO_UNIX_SOCKETS
     struct sockaddr_un uaddr;
 #endif
     struct sockaddr *addr;
     socklen_t addrlen;
 
-#ifndef _WIN32
+#ifndef NO_UNIX_SOCKETS
     if (is_unix) {
        addr = (struct sockaddr *)&uaddr;
        addrlen = sizeof(uaddr);
@@ -3414,7 +3416,7 @@ static CharDriverState *qemu_chr_open_tcp(const char *host_str,
     if (!s)
         goto fail;
 
-#ifndef _WIN32
+#ifndef NO_UNIX_SOCKETS
     if (is_unix)
        fd = socket(PF_UNIX, SOCK_STREAM, 0);
     else
@@ -3439,7 +3441,7 @@ static CharDriverState *qemu_chr_open_tcp(const char *host_str,
 
     if (is_listen) {
         /* allow fast reuse */
-#ifndef _WIN32
+#ifndef NO_UNIX_SOCKETS
        if (is_unix) {
            char path[109];
            strncpy(path, uaddr.sun_path, 108);
@@ -4270,7 +4272,7 @@ static int tap_open(char *ifname, int ifname_size)
     fcntl(fd, F_SETFL, O_NONBLOCK);
     return fd;
 }
-#else
+#elif defined(__linux__)
 static int tap_open(char *ifname, int ifname_size)
 {
     struct ifreq ifr;
@@ -8699,7 +8701,17 @@ int main(int argc, char **argv)
     bdrv_init();
 
     xc_handle = xc_interface_open();
+#ifdef CONFIG_STUBDOM
+    {
+        char *domid_s, *msg;
+        if ((msg = xenbus_read(XBT_NIL, "domid", &domid_s)))
+            fprintf(stderr,"Can not read our own domid: %s\n", msg);
+        else
+            xenstore_parse_domain_config(atoi(domid_s));
+    }
+#else
     xenstore_parse_domain_config(domid);
+#endif /* CONFIG_STUBDOM */
 
     /* we always create the cdrom drive, even if no disk is there */
 
@@ -8729,6 +8741,10 @@ int main(int argc, char **argv)
 
     /* terminal init */
     memset(&display_state, 0, sizeof(display_state));
+#ifdef CONFIG_STUBDOM
+    if (xenfb_pv_display_init(ds) == 0) {
+    } else
+#endif
     if (nographic) {
         if (curses) {
             fprintf(stderr, "fatal: -nographic can't be used with -curses\n");
index 4baada2b3af2feff8e79343f39e39b2a6e65b94f..8c3dc6b31271ad0be6df1e8297eefc3c86a23450 100644 (file)
@@ -88,3 +88,20 @@ void do_loadvm(const char *name)
 struct qemu_alarm_timer;
 static int unix_start_timer(struct qemu_alarm_timer *t) { return 0; }
 static void unix_stop_timer(struct qemu_alarm_timer *t) { }
+
+#ifdef CONFIG_STUBDOM
+#include <netfront.h>
+static int tap_open(char *ifname, int ifname_size)
+{
+    char nodename[64];
+    static int num = 1; // 0 is for our own TCP/IP networking
+    snprintf(nodename, sizeof(nodename), "device/vif/%d", num++);
+    return netfront_tap_open(nodename);
+}
+
+#undef DEFAULT_NETWORK_SCRIPT
+#define DEFAULT_NETWORK_SCRIPT ""
+#undef DEFAULT_NETWORK_DOWN_SCRIPT
+#define DEFAULT_NETWORK_DOWN_SCRIPT ""
+#endif
+
index 16691fdde4fabf318cb13976b9c36ed66bfd47e9..3a67ada9a1b4c14d776f2ac61687bafb823370c2 100644 (file)
@@ -4,11 +4,12 @@
 #include <semaphore.h>
 #include <sched.h>
 #include <fbfront.h>
+#include <hw/hw.h>
+#include <hw/pc.h>
+#include <console.h>
 
 #include <hw/xenfb.h>
 
-#include "vl.h"
-
 typedef struct XenFBState {
     struct semaphore kbd_sem;
     struct kbdfront_dev *kbd_dev;
@@ -70,6 +71,7 @@ static void xenfb_pv_resize_shared(DisplayState *ds, int w, int h, int depth, in
     if (ds->shared_buf) {
         offset = pixels - xs->vga_vram;
         ds->data = pixels;
+        fbfront_resize(fb_dev, ds->width, ds->height, ds->linesize, ds->depth, offset);
     } else {
         ds->data = xs->nonshared_vram;
         fbfront_resize(fb_dev, w, h, linesize, ds->depth, VGA_RAM_SIZE);
index c0fe95a50db07d022bea3c17464a75ae44179f7a..99792c421e7618fc87a3283165101a3a43e80678 100644 (file)
@@ -305,8 +305,7 @@ void xenstore_parse_domain_config(int hvm_domid)
             continue;
        if (bdrv_open2(bs, buf, 0 /* snapshot */, &bdrv_vbd) == 0) {
            pstrcpy(bs->filename, sizeof(bs->filename), params);
-           continue;
-       }
+       } else
 #endif
 
         if (params[0]) {