[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 2 of 3] [QEMU remote] Fixes to source files to compile as a stubdomain



Various fixes to some source files to compile as a stubdomain.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>

---
 block-vbd.c       |    3 ++-
 exec-all.h        |    6 +++++-
 hw/scsi-disk.c    |    2 +-
 hw/vga.c          |    3 +++
 i386-dm/exec-dm.c |    4 ++--
 vl.c              |   32 ++++++++++++++++++++++++--------
 xen-vl-extra.c    |   17 +++++++++++++++++
 xenfbfront.c      |    6 ++++--
 xenstore.c        |    3 +--
 9 files changed, 59 insertions(+), 17 deletions(-)

diff --git a/block-vbd.c b/block-vbd.c
index 10f7a21..9c74952 100644
--- a/block-vbd.c
+++ b/block-vbd.c
@@ -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>
diff --git a/exec-all.h b/exec-all.h
index 8d4e6f6..f9475df 100644
--- a/exec-all.h
+++ b/exec-all.h
@@ -307,7 +307,9 @@ extern void *io_mem_opaque[IO_MEM_NB_ENTRIES];
 
 #include <spinlock.h>
 
-#elif defined(__hppa__)
+#else
+
+#if defined(__hppa__)
 
 typedef int spinlock_t[4];
 
@@ -519,6 +521,8 @@ static inline int spin_trylock(spinlock_t *lock)
 }
 #endif
 
+#endif
+
 extern spinlock_t tb_lock;
 
 extern int tb_invalidated_flag;
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 3f78166..e3d8069 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -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
diff --git a/hw/vga.c b/hw/vga.c
index 9e0dea8..65c710a 100644
--- 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
diff --git a/i386-dm/exec-dm.c b/i386-dm/exec-dm.c
index d511021..dec4aa8 100644
--- a/i386-dm/exec-dm.c
+++ b/i386-dm/exec-dm.c
@@ -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 3f14553..e215af7 100644
--- 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");
diff --git a/xen-vl-extra.c b/xen-vl-extra.c
index 4baada2..8c3dc6b 100644
--- a/xen-vl-extra.c
+++ b/xen-vl-extra.c
@@ -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
+
diff --git a/xenfbfront.c b/xenfbfront.c
index 16691fd..3a67ada 100644
--- a/xenfbfront.c
+++ b/xenfbfront.c
@@ -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);
diff --git a/xenstore.c b/xenstore.c
index c0fe95a..99792c4 100644
--- a/xenstore.c
+++ b/xenstore.c
@@ -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]) {
-- 
1.5.4.3


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.