Skip to content

Commit

Permalink
Merge remote branch 'spice/submit.6' into staging
Browse files Browse the repository at this point in the history
Conflicts:
	configure

Signed-off-by: Anthony Liguori <[email protected]>
  • Loading branch information
Anthony Liguori committed Oct 5, 2010
2 parents 48f5704 + 869564a commit 4447d60
Show file tree
Hide file tree
Showing 15 changed files with 1,287 additions and 19 deletions.
3 changes: 3 additions & 0 deletions Makefile.objs
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,14 @@ common-obj-y += qemu-char.o savevm.o #aio.o
common-obj-y += msmouse.o ps2.o
common-obj-y += qdev.o qdev-properties.o
common-obj-y += block-migration.o
common-obj-y += pflib.o

common-obj-$(CONFIG_BRLAPI) += baum.o
common-obj-$(CONFIG_POSIX) += migration-exec.o migration-unix.o migration-fd.o
common-obj-$(CONFIG_WIN32) += version.o

common-obj-$(CONFIG_SPICE) += ui/spice-core.o ui/spice-input.o ui/spice-display.o

audio-obj-y = audio.o noaudio.o wavaudio.o mixeng.o
audio-obj-$(CONFIG_SDL) += sdlaudio.o
audio-obj-$(CONFIG_OSS) += ossaudio.o
Expand Down
42 changes: 40 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@ TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
# NB: do not call "exit" in the trap handler; this is buggy with some shells;
# see <[email protected]>
trap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
rm -f config.log

compile_object() {
$cc $QEMU_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
echo $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log
$cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log 2>&1
}

compile_prog() {
local_cflags="$1"
local_ldflags="$2"
$cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > /dev/null 2> /dev/null
echo $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags >> config.log
$cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags >> config.log 2>&1
}

# check whether a command is available to this shell (may be either an
Expand Down Expand Up @@ -327,6 +330,7 @@ user_pie="no"
zero_malloc=""
trace_backend="nop"
trace_file="trace"
spice=""

# OS specific
if check_define __linux__ ; then
Expand Down Expand Up @@ -639,6 +643,10 @@ for opt do
;;
--enable-kvm) kvm="yes"
;;
--disable-spice) spice="no"
;;
--enable-spice) spice="yes"
;;
--enable-profiler) profiler="yes"
;;
--enable-cocoa)
Expand Down Expand Up @@ -921,6 +929,8 @@ echo " --enable-vhost-net enable vhost-net acceleration support"
echo " --trace-backend=B Trace backend nop simple ust"
echo " --trace-file=NAME Full PATH,NAME of file to store traces"
echo " Default:trace-<pid>"
echo " --disable-spice disable spice"
echo " --enable-spice enable spice"
echo ""
echo "NOTE: The object files are built at the place where configure is launched"
exit 1
Expand Down Expand Up @@ -2075,6 +2085,29 @@ if compile_prog "" ""; then
gcc_attribute_warn_unused_result=yes
fi

# spice probe
if test "$spice" != "no" ; then
cat > $TMPC << EOF
#include <spice.h>
int main(void) { spice_server_new(); return 0; }
EOF
spice_cflags=$($pkgconfig --cflags spice-protocol spice-server 2>/dev/null)
spice_libs=$($pkgconfig --libs spice-protocol spice-server 2>/dev/null)
if $pkgconfig --atleast-version=0.5.3 spice-server &&\
compile_prog "$spice_cflags" "$spice_libs" ; then
spice="yes"
libs_softmmu="$libs_softmmu $spice_libs"
QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
else
if test "$spice" = "yes" ; then
feature_not_found "spice"
fi
spice="no"
fi
fi

##########################################

##########################################
# check if we have fdatasync

Expand Down Expand Up @@ -2285,6 +2318,7 @@ echo "uuid support $uuid"
echo "vhost-net support $vhost_net"
echo "Trace backend $trace_backend"
echo "Trace output file $trace_file-<pid>"
echo "spice support $spice"

if test $sdl_too_old = "yes"; then
echo "-> Your SDL version is too old - please upgrade to have SDL support"
Expand Down Expand Up @@ -2540,6 +2574,10 @@ if test "$posix_madvise" = "yes" ; then
echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
fi

if test "$spice" = "yes" ; then
echo "CONFIG_SPICE=y" >> $config_host_mak
fi

# XXX: suppress that
if [ "$bsd" = "yes" ] ; then
echo "CONFIG_BSD=y" >> $config_host_mak
Expand Down
9 changes: 9 additions & 0 deletions fsdev/qemu-fsdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "qemu-queue.h"
#include "osdep.h"
#include "qemu-common.h"
#include "qemu-config.h"

static QTAILQ_HEAD(FsTypeEntry_head, FsTypeListEntry) fstype_entries =
QTAILQ_HEAD_INITIALIZER(fstype_entries);
Expand Down Expand Up @@ -75,3 +76,11 @@ FsTypeEntry *get_fsdev_fsentry(char *id)
}
return NULL;
}

static void fsdev_register_config(void)
{
qemu_add_opts(&qemu_fsdev_opts);
qemu_add_opts(&qemu_virtfs_opts);
}
machine_init(fsdev_register_config);

213 changes: 213 additions & 0 deletions pflib.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
/*
* PixelFormat conversion library.
*
* Author: Gerd Hoffmann <[email protected]>
*
* This work is licensed under the terms of the GNU GPL, version 2. See
* the COPYING file in the top-level directory.
*
*/
#include "qemu-common.h"
#include "console.h"
#include "pflib.h"

typedef struct QemuPixel QemuPixel;

typedef void (*pf_convert)(QemuPfConv *conv,
void *dst, void *src, uint32_t cnt);
typedef void (*pf_convert_from)(PixelFormat *pf,
QemuPixel *dst, void *src, uint32_t cnt);
typedef void (*pf_convert_to)(PixelFormat *pf,
void *dst, QemuPixel *src, uint32_t cnt);

struct QemuPfConv {
pf_convert convert;
PixelFormat src;
PixelFormat dst;

/* for copy_generic() */
pf_convert_from conv_from;
pf_convert_to conv_to;
QemuPixel *conv_buf;
uint32_t conv_cnt;
};

struct QemuPixel {
uint8_t red;
uint8_t green;
uint8_t blue;
uint8_t alpha;
};

/* ----------------------------------------------------------------------- */
/* PixelFormat -> QemuPixel conversions */

static void conv_16_to_pixel(PixelFormat *pf,
QemuPixel *dst, void *src, uint32_t cnt)
{
uint16_t *src16 = src;

while (cnt > 0) {
dst->red = ((*src16 & pf->rmask) >> pf->rshift) << (8 - pf->rbits);
dst->green = ((*src16 & pf->gmask) >> pf->gshift) << (8 - pf->gbits);
dst->blue = ((*src16 & pf->bmask) >> pf->bshift) << (8 - pf->bbits);
dst->alpha = ((*src16 & pf->amask) >> pf->ashift) << (8 - pf->abits);
dst++, src16++, cnt--;
}
}

/* assumes pf->{r,g,b,a}bits == 8 */
static void conv_32_to_pixel_fast(PixelFormat *pf,
QemuPixel *dst, void *src, uint32_t cnt)
{
uint32_t *src32 = src;

while (cnt > 0) {
dst->red = (*src32 & pf->rmask) >> pf->rshift;
dst->green = (*src32 & pf->gmask) >> pf->gshift;
dst->blue = (*src32 & pf->bmask) >> pf->bshift;
dst->alpha = (*src32 & pf->amask) >> pf->ashift;
dst++, src32++, cnt--;
}
}

static void conv_32_to_pixel_generic(PixelFormat *pf,
QemuPixel *dst, void *src, uint32_t cnt)
{
uint32_t *src32 = src;

while (cnt > 0) {
if (pf->rbits < 8) {
dst->red = ((*src32 & pf->rmask) >> pf->rshift) << (8 - pf->rbits);
} else {
dst->red = ((*src32 & pf->rmask) >> pf->rshift) >> (pf->rbits - 8);
}
if (pf->gbits < 8) {
dst->green = ((*src32 & pf->gmask) >> pf->gshift) << (8 - pf->gbits);
} else {
dst->green = ((*src32 & pf->gmask) >> pf->gshift) >> (pf->gbits - 8);
}
if (pf->bbits < 8) {
dst->blue = ((*src32 & pf->bmask) >> pf->bshift) << (8 - pf->bbits);
} else {
dst->blue = ((*src32 & pf->bmask) >> pf->bshift) >> (pf->bbits - 8);
}
if (pf->abits < 8) {
dst->alpha = ((*src32 & pf->amask) >> pf->ashift) << (8 - pf->abits);
} else {
dst->alpha = ((*src32 & pf->amask) >> pf->ashift) >> (pf->abits - 8);
}
dst++, src32++, cnt--;
}
}

/* ----------------------------------------------------------------------- */
/* QemuPixel -> PixelFormat conversions */

static void conv_pixel_to_16(PixelFormat *pf,
void *dst, QemuPixel *src, uint32_t cnt)
{
uint16_t *dst16 = dst;

while (cnt > 0) {
*dst16 = ((uint16_t)src->red >> (8 - pf->rbits)) << pf->rshift;
*dst16 |= ((uint16_t)src->green >> (8 - pf->gbits)) << pf->gshift;
*dst16 |= ((uint16_t)src->blue >> (8 - pf->bbits)) << pf->bshift;
*dst16 |= ((uint16_t)src->alpha >> (8 - pf->abits)) << pf->ashift;
dst16++, src++, cnt--;
}
}

static void conv_pixel_to_32(PixelFormat *pf,
void *dst, QemuPixel *src, uint32_t cnt)
{
uint32_t *dst32 = dst;

while (cnt > 0) {
*dst32 = ((uint32_t)src->red >> (8 - pf->rbits)) << pf->rshift;
*dst32 |= ((uint32_t)src->green >> (8 - pf->gbits)) << pf->gshift;
*dst32 |= ((uint32_t)src->blue >> (8 - pf->bbits)) << pf->bshift;
*dst32 |= ((uint32_t)src->alpha >> (8 - pf->abits)) << pf->ashift;
dst32++, src++, cnt--;
}
}

/* ----------------------------------------------------------------------- */
/* PixelFormat -> PixelFormat conversions */

static void convert_copy(QemuPfConv *conv, void *dst, void *src, uint32_t cnt)
{
uint32_t bytes = cnt * conv->src.bytes_per_pixel;
memcpy(dst, src, bytes);
}

static void convert_generic(QemuPfConv *conv, void *dst, void *src, uint32_t cnt)
{
if (conv->conv_cnt < cnt) {
conv->conv_cnt = cnt;
conv->conv_buf = qemu_realloc(conv->conv_buf, sizeof(QemuPixel) * conv->conv_cnt);
}
conv->conv_from(&conv->src, conv->conv_buf, src, cnt);
conv->conv_to(&conv->dst, dst, conv->conv_buf, cnt);
}

/* ----------------------------------------------------------------------- */
/* public interface */

QemuPfConv *qemu_pf_conv_get(PixelFormat *dst, PixelFormat *src)
{
QemuPfConv *conv = qemu_mallocz(sizeof(QemuPfConv));

conv->src = *src;
conv->dst = *dst;

if (memcmp(&conv->src, &conv->dst, sizeof(PixelFormat)) == 0) {
/* formats identical, can simply copy */
conv->convert = convert_copy;
} else {
/* generic two-step conversion: src -> QemuPixel -> dst */
switch (conv->src.bytes_per_pixel) {
case 2:
conv->conv_from = conv_16_to_pixel;
break;
case 4:
if (conv->src.rbits == 8 && conv->src.gbits == 8 && conv->src.bbits == 8) {
conv->conv_from = conv_32_to_pixel_fast;
} else {
conv->conv_from = conv_32_to_pixel_generic;
}
break;
default:
goto err;
}
switch (conv->dst.bytes_per_pixel) {
case 2:
conv->conv_to = conv_pixel_to_16;
break;
case 4:
conv->conv_to = conv_pixel_to_32;
break;
default:
goto err;
}
conv->convert = convert_generic;
}
return conv;

err:
qemu_free(conv);
return NULL;
}

void qemu_pf_conv_run(QemuPfConv *conv, void *dst, void *src, uint32_t cnt)
{
conv->convert(conv, dst, src, cnt);
}

void qemu_pf_conv_put(QemuPfConv *conv)
{
if (conv) {
qemu_free(conv->conv_buf);
qemu_free(conv);
}
}
20 changes: 20 additions & 0 deletions pflib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef __QEMU_PFLIB_H
#define __QEMU_PFLIB_H

/*
* PixelFormat conversion library.
*
* Author: Gerd Hoffmann <[email protected]>
*
* This work is licensed under the terms of the GNU GPL, version 2. See
* the COPYING file in the top-level directory.
*
*/

typedef struct QemuPfConv QemuPfConv;

QemuPfConv *qemu_pf_conv_get(PixelFormat *dst, PixelFormat *src);
void qemu_pf_conv_run(QemuPfConv *conv, void *dst, void *src, uint32_t cnt);
void qemu_pf_conv_put(QemuPfConv *conv);

#endif
18 changes: 18 additions & 0 deletions qemu-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,24 @@ static QemuOptsList qemu_cpudef_opts = {
},
};

QemuOptsList qemu_spice_opts = {
.name = "spice",
.head = QTAILQ_HEAD_INITIALIZER(qemu_spice_opts.head),
.desc = {
{
.name = "port",
.type = QEMU_OPT_NUMBER,
},{
.name = "password",
.type = QEMU_OPT_STRING,
},{
.name = "disable-ticketing",
.type = QEMU_OPT_BOOL,
},
{ /* end if list */ }
},
};

static QemuOptsList *vm_config_groups[32] = {
&qemu_drive_opts,
&qemu_chardev_opts,
Expand Down
Loading

0 comments on commit 4447d60

Please sign in to comment.