mirror of https://github.com/xemu-project/xemu.git
Merge remote-tracking branch 'jvrao/for-anthony' into staging
This commit is contained in:
commit
93e0597ef9
|
@ -45,12 +45,14 @@ net-nested-$(CONFIG_SLIRP) += slirp.o
|
||||||
net-nested-$(CONFIG_VDE) += vde.o
|
net-nested-$(CONFIG_VDE) += vde.o
|
||||||
net-obj-y += $(addprefix net/, $(net-nested-y))
|
net-obj-y += $(addprefix net/, $(net-nested-y))
|
||||||
|
|
||||||
ifeq ($(CONFIG_VIRTIO)$(CONFIG_VIRTFS),yy)
|
ifeq ($(CONFIG_VIRTIO)$(CONFIG_VIRTFS)$(CONFIG_PCI),yyy)
|
||||||
# Lots of the fsdev/9pcode is pulled in by vl.c via qemu_fsdev_add.
|
# Lots of the fsdev/9pcode is pulled in by vl.c via qemu_fsdev_add.
|
||||||
# only pull in the actual virtio-9p device if we also enabled virtio.
|
# only pull in the actual virtio-9p device if we also enabled virtio.
|
||||||
CONFIG_REALLY_VIRTFS=y
|
CONFIG_REALLY_VIRTFS=y
|
||||||
|
fsdev-nested-y = qemu-fsdev.o
|
||||||
|
else
|
||||||
|
fsdev-nested-y = qemu-fsdev-dummy.o
|
||||||
endif
|
endif
|
||||||
fsdev-nested-$(CONFIG_VIRTFS) = qemu-fsdev.o
|
|
||||||
fsdev-obj-$(CONFIG_VIRTFS) += $(addprefix fsdev/, $(fsdev-nested-y))
|
fsdev-obj-$(CONFIG_VIRTFS) += $(addprefix fsdev/, $(fsdev-nested-y))
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
@ -286,12 +288,11 @@ sound-obj-$(CONFIG_HDA) += intel-hda.o hda-audio.o
|
||||||
adlib.o fmopl.o: QEMU_CFLAGS += -DBUILD_Y8950=0
|
adlib.o fmopl.o: QEMU_CFLAGS += -DBUILD_Y8950=0
|
||||||
hw-obj-$(CONFIG_SOUND) += $(sound-obj-y)
|
hw-obj-$(CONFIG_SOUND) += $(sound-obj-y)
|
||||||
|
|
||||||
9pfs-nested-$(CONFIG_REALLY_VIRTFS) = virtio-9p-debug.o
|
9pfs-nested-$(CONFIG_VIRTFS) = virtio-9p.o virtio-9p-debug.o
|
||||||
9pfs-nested-$(CONFIG_VIRTFS) += virtio-9p-local.o virtio-9p-xattr.o
|
9pfs-nested-$(CONFIG_VIRTFS) += virtio-9p-local.o virtio-9p-xattr.o
|
||||||
9pfs-nested-$(CONFIG_VIRTFS) += virtio-9p-xattr-user.o virtio-9p-posix-acl.o
|
9pfs-nested-$(CONFIG_VIRTFS) += virtio-9p-xattr-user.o virtio-9p-posix-acl.o
|
||||||
|
|
||||||
hw-obj-$(CONFIG_VIRTFS) += $(addprefix 9pfs/, $(9pfs-nested-y))
|
hw-obj-$(CONFIG_REALLY_VIRTFS) += $(addprefix 9pfs/, $(9pfs-nested-y))
|
||||||
$(addprefix 9pfs/, $(9pfs-nested-y)): CFLAGS += -I$(SRC_PATH)/hw/
|
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
|
@ -192,7 +192,7 @@ obj-$(CONFIG_NO_PCI) += pci-stub.o
|
||||||
obj-$(CONFIG_VIRTIO) += virtio-blk.o virtio-balloon.o virtio-net.o virtio-serial-bus.o
|
obj-$(CONFIG_VIRTIO) += virtio-blk.o virtio-balloon.o virtio-net.o virtio-serial-bus.o
|
||||||
obj-y += vhost_net.o
|
obj-y += vhost_net.o
|
||||||
obj-$(CONFIG_VHOST_NET) += vhost.o
|
obj-$(CONFIG_VHOST_NET) += vhost.o
|
||||||
obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/virtio-9p.o
|
obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/virtio-9p-device.o
|
||||||
obj-y += rwhandler.o
|
obj-y += rwhandler.o
|
||||||
obj-$(CONFIG_KVM) += kvm.o kvm-all.o
|
obj-$(CONFIG_KVM) += kvm.o kvm-all.o
|
||||||
obj-$(CONFIG_NO_KVM) += kvm-stub.o
|
obj-$(CONFIG_NO_KVM) += kvm-stub.o
|
||||||
|
@ -411,8 +411,6 @@ hmp-commands.h: $(SRC_PATH)/hmp-commands.hx
|
||||||
qmp-commands.h: $(SRC_PATH)/qmp-commands.hx
|
qmp-commands.h: $(SRC_PATH)/qmp-commands.hx
|
||||||
$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $(TARGET_DIR)$@")
|
$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $(TARGET_DIR)$@")
|
||||||
|
|
||||||
9pfs/virtio-9p.o: CFLAGS += -I$(SRC_PATH)/hw/
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o *.a *~ $(PROGS) nwfpe/*.o fpu/*.o
|
rm -f *.o *.a *~ $(PROGS) nwfpe/*.o fpu/*.o
|
||||||
rm -f *.d */*.d tcg/*.o ide/*.o 9pfs/*.o
|
rm -f *.d */*.d tcg/*.o ide/*.o 9pfs/*.o
|
||||||
|
|
|
@ -97,11 +97,4 @@ typedef struct FileOperations
|
||||||
void *opaque;
|
void *opaque;
|
||||||
} FileOperations;
|
} FileOperations;
|
||||||
|
|
||||||
static inline const char *rpath(FsContext *ctx, const char *path)
|
|
||||||
{
|
|
||||||
/* FIXME: so wrong... */
|
|
||||||
static char buffer[4096];
|
|
||||||
snprintf(buffer, sizeof(buffer), "%s/%s", ctx->fs_root, path);
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
/*
|
||||||
|
* Virtio 9p
|
||||||
|
*
|
||||||
|
* Copyright IBM, Corp. 2010
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Gautham R Shenoy <ego@in.ibm.com>
|
||||||
|
*
|
||||||
|
* This work is licensed under the terms of the GNU GPL, version 2. See
|
||||||
|
* the COPYING file in the top-level directory.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "qemu-fsdev.h"
|
||||||
|
|
||||||
|
int qemu_fsdev_add(QemuOpts *opts)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -10,8 +10,9 @@
|
||||||
* the COPYING file in the top-level directory.
|
* the COPYING file in the top-level directory.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "virtio.h"
|
|
||||||
#include "pc.h"
|
#include "hw/virtio.h"
|
||||||
|
#include "hw/pc.h"
|
||||||
#include "virtio-9p.h"
|
#include "virtio-9p.h"
|
||||||
#include "virtio-9p-debug.h"
|
#include "virtio-9p-debug.h"
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,173 @@
|
||||||
|
/*
|
||||||
|
* Virtio 9p backend
|
||||||
|
*
|
||||||
|
* Copyright IBM, Corp. 2010
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Anthony Liguori <aliguori@us.ibm.com>
|
||||||
|
*
|
||||||
|
* This work is licensed under the terms of the GNU GPL, version 2. See
|
||||||
|
* the COPYING file in the top-level directory.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "hw/virtio.h"
|
||||||
|
#include "hw/pc.h"
|
||||||
|
#include "qemu_socket.h"
|
||||||
|
#include "hw/virtio-pci.h"
|
||||||
|
#include "virtio-9p.h"
|
||||||
|
#include "fsdev/qemu-fsdev.h"
|
||||||
|
#include "virtio-9p-xattr.h"
|
||||||
|
|
||||||
|
static uint32_t virtio_9p_get_features(VirtIODevice *vdev, uint32_t features)
|
||||||
|
{
|
||||||
|
features |= 1 << VIRTIO_9P_MOUNT_TAG;
|
||||||
|
return features;
|
||||||
|
}
|
||||||
|
|
||||||
|
static V9fsState *to_virtio_9p(VirtIODevice *vdev)
|
||||||
|
{
|
||||||
|
return (V9fsState *)vdev;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config)
|
||||||
|
{
|
||||||
|
struct virtio_9p_config *cfg;
|
||||||
|
V9fsState *s = to_virtio_9p(vdev);
|
||||||
|
|
||||||
|
cfg = qemu_mallocz(sizeof(struct virtio_9p_config) +
|
||||||
|
s->tag_len);
|
||||||
|
stw_raw(&cfg->tag_len, s->tag_len);
|
||||||
|
memcpy(cfg->tag, s->tag, s->tag_len);
|
||||||
|
memcpy(config, cfg, s->config_size);
|
||||||
|
qemu_free(cfg);
|
||||||
|
}
|
||||||
|
|
||||||
|
VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
|
||||||
|
{
|
||||||
|
V9fsState *s;
|
||||||
|
int i, len;
|
||||||
|
struct stat stat;
|
||||||
|
FsTypeEntry *fse;
|
||||||
|
|
||||||
|
|
||||||
|
s = (V9fsState *)virtio_common_init("virtio-9p",
|
||||||
|
VIRTIO_ID_9P,
|
||||||
|
sizeof(struct virtio_9p_config)+
|
||||||
|
MAX_TAG_LEN,
|
||||||
|
sizeof(V9fsState));
|
||||||
|
|
||||||
|
/* initialize pdu allocator */
|
||||||
|
QLIST_INIT(&s->free_list);
|
||||||
|
for (i = 0; i < (MAX_REQ - 1); i++) {
|
||||||
|
QLIST_INSERT_HEAD(&s->free_list, &s->pdus[i], next);
|
||||||
|
}
|
||||||
|
|
||||||
|
s->vq = virtio_add_queue(&s->vdev, MAX_REQ, handle_9p_output);
|
||||||
|
|
||||||
|
fse = get_fsdev_fsentry(conf->fsdev_id);
|
||||||
|
|
||||||
|
if (!fse) {
|
||||||
|
/* We don't have a fsdev identified by fsdev_id */
|
||||||
|
fprintf(stderr, "Virtio-9p device couldn't find fsdev with the "
|
||||||
|
"id = %s\n", conf->fsdev_id ? conf->fsdev_id : "NULL");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fse->path || !conf->tag) {
|
||||||
|
/* we haven't specified a mount_tag or the path */
|
||||||
|
fprintf(stderr, "fsdev with id %s needs path "
|
||||||
|
"and Virtio-9p device needs mount_tag arguments\n",
|
||||||
|
conf->fsdev_id);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcmp(fse->security_model, "passthrough")) {
|
||||||
|
/* Files on the Fileserver set to client user credentials */
|
||||||
|
s->ctx.fs_sm = SM_PASSTHROUGH;
|
||||||
|
s->ctx.xops = passthrough_xattr_ops;
|
||||||
|
} else if (!strcmp(fse->security_model, "mapped")) {
|
||||||
|
/* Files on the fileserver are set to QEMU credentials.
|
||||||
|
* Client user credentials are saved in extended attributes.
|
||||||
|
*/
|
||||||
|
s->ctx.fs_sm = SM_MAPPED;
|
||||||
|
s->ctx.xops = mapped_xattr_ops;
|
||||||
|
} else if (!strcmp(fse->security_model, "none")) {
|
||||||
|
/*
|
||||||
|
* Files on the fileserver are set to QEMU credentials.
|
||||||
|
*/
|
||||||
|
s->ctx.fs_sm = SM_NONE;
|
||||||
|
s->ctx.xops = none_xattr_ops;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Default to security_model=none. You may want"
|
||||||
|
" enable advanced security model using "
|
||||||
|
"security option:\n\t security_model=passthrough\n\t "
|
||||||
|
"security_model=mapped\n");
|
||||||
|
s->ctx.fs_sm = SM_NONE;
|
||||||
|
s->ctx.xops = none_xattr_ops;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lstat(fse->path, &stat)) {
|
||||||
|
fprintf(stderr, "share path %s does not exist\n", fse->path);
|
||||||
|
exit(1);
|
||||||
|
} else if (!S_ISDIR(stat.st_mode)) {
|
||||||
|
fprintf(stderr, "share path %s is not a directory\n", fse->path);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
s->ctx.fs_root = qemu_strdup(fse->path);
|
||||||
|
len = strlen(conf->tag);
|
||||||
|
if (len > MAX_TAG_LEN) {
|
||||||
|
len = MAX_TAG_LEN;
|
||||||
|
}
|
||||||
|
/* s->tag is non-NULL terminated string */
|
||||||
|
s->tag = qemu_malloc(len);
|
||||||
|
memcpy(s->tag, conf->tag, len);
|
||||||
|
s->tag_len = len;
|
||||||
|
s->ctx.uid = -1;
|
||||||
|
|
||||||
|
s->ops = fse->ops;
|
||||||
|
s->vdev.get_features = virtio_9p_get_features;
|
||||||
|
s->config_size = sizeof(struct virtio_9p_config) +
|
||||||
|
s->tag_len;
|
||||||
|
s->vdev.get_config = virtio_9p_get_config;
|
||||||
|
|
||||||
|
return &s->vdev;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int virtio_9p_init_pci(PCIDevice *pci_dev)
|
||||||
|
{
|
||||||
|
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
|
||||||
|
VirtIODevice *vdev;
|
||||||
|
|
||||||
|
vdev = virtio_9p_init(&pci_dev->qdev, &proxy->fsconf);
|
||||||
|
vdev->nvectors = proxy->nvectors;
|
||||||
|
virtio_init_pci(proxy, vdev,
|
||||||
|
PCI_VENDOR_ID_REDHAT_QUMRANET,
|
||||||
|
0x1009,
|
||||||
|
0x2,
|
||||||
|
0x00);
|
||||||
|
/* make the actual value visible */
|
||||||
|
proxy->nvectors = vdev->nvectors;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PCIDeviceInfo virtio_9p_info = {
|
||||||
|
.qdev.name = "virtio-9p-pci",
|
||||||
|
.qdev.size = sizeof(VirtIOPCIProxy),
|
||||||
|
.init = virtio_9p_init_pci,
|
||||||
|
.qdev.props = (Property[]) {
|
||||||
|
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
|
||||||
|
DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),
|
||||||
|
DEFINE_PROP_STRING("mount_tag", VirtIOPCIProxy, fsconf.tag),
|
||||||
|
DEFINE_PROP_STRING("fsdev", VirtIOPCIProxy, fsconf.fsdev_id),
|
||||||
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static void virtio_9p_register_devices(void)
|
||||||
|
{
|
||||||
|
pci_qdev_register(&virtio_9p_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
device_init(virtio_9p_register_devices)
|
|
@ -10,7 +10,8 @@
|
||||||
* the COPYING file in the top-level directory.
|
* the COPYING file in the top-level directory.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "virtio.h"
|
|
||||||
|
#include "hw/virtio.h"
|
||||||
#include "virtio-9p.h"
|
#include "virtio-9p.h"
|
||||||
#include "virtio-9p-xattr.h"
|
#include "virtio-9p-xattr.h"
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
@ -24,7 +25,8 @@
|
||||||
static int local_lstat(FsContext *fs_ctx, const char *path, struct stat *stbuf)
|
static int local_lstat(FsContext *fs_ctx, const char *path, struct stat *stbuf)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
err = lstat(rpath(fs_ctx, path), stbuf);
|
char buffer[PATH_MAX];
|
||||||
|
err = lstat(rpath(fs_ctx, path, buffer), stbuf);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -34,19 +36,19 @@ static int local_lstat(FsContext *fs_ctx, const char *path, struct stat *stbuf)
|
||||||
gid_t tmp_gid;
|
gid_t tmp_gid;
|
||||||
mode_t tmp_mode;
|
mode_t tmp_mode;
|
||||||
dev_t tmp_dev;
|
dev_t tmp_dev;
|
||||||
if (getxattr(rpath(fs_ctx, path), "user.virtfs.uid", &tmp_uid,
|
if (getxattr(rpath(fs_ctx, path, buffer), "user.virtfs.uid", &tmp_uid,
|
||||||
sizeof(uid_t)) > 0) {
|
sizeof(uid_t)) > 0) {
|
||||||
stbuf->st_uid = tmp_uid;
|
stbuf->st_uid = tmp_uid;
|
||||||
}
|
}
|
||||||
if (getxattr(rpath(fs_ctx, path), "user.virtfs.gid", &tmp_gid,
|
if (getxattr(rpath(fs_ctx, path, buffer), "user.virtfs.gid", &tmp_gid,
|
||||||
sizeof(gid_t)) > 0) {
|
sizeof(gid_t)) > 0) {
|
||||||
stbuf->st_gid = tmp_gid;
|
stbuf->st_gid = tmp_gid;
|
||||||
}
|
}
|
||||||
if (getxattr(rpath(fs_ctx, path), "user.virtfs.mode", &tmp_mode,
|
if (getxattr(rpath(fs_ctx, path, buffer), "user.virtfs.mode",
|
||||||
sizeof(mode_t)) > 0) {
|
&tmp_mode, sizeof(mode_t)) > 0) {
|
||||||
stbuf->st_mode = tmp_mode;
|
stbuf->st_mode = tmp_mode;
|
||||||
}
|
}
|
||||||
if (getxattr(rpath(fs_ctx, path), "user.virtfs.rdev", &tmp_dev,
|
if (getxattr(rpath(fs_ctx, path, buffer), "user.virtfs.rdev", &tmp_dev,
|
||||||
sizeof(dev_t)) > 0) {
|
sizeof(dev_t)) > 0) {
|
||||||
stbuf->st_rdev = tmp_dev;
|
stbuf->st_rdev = tmp_dev;
|
||||||
}
|
}
|
||||||
|
@ -91,10 +93,12 @@ static int local_set_xattr(const char *path, FsCred *credp)
|
||||||
static int local_post_create_passthrough(FsContext *fs_ctx, const char *path,
|
static int local_post_create_passthrough(FsContext *fs_ctx, const char *path,
|
||||||
FsCred *credp)
|
FsCred *credp)
|
||||||
{
|
{
|
||||||
if (chmod(rpath(fs_ctx, path), credp->fc_mode & 07777) < 0) {
|
char buffer[PATH_MAX];
|
||||||
|
if (chmod(rpath(fs_ctx, path, buffer), credp->fc_mode & 07777) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (lchown(rpath(fs_ctx, path), credp->fc_uid, credp->fc_gid) < 0) {
|
if (lchown(rpath(fs_ctx, path, buffer), credp->fc_uid,
|
||||||
|
credp->fc_gid) < 0) {
|
||||||
/*
|
/*
|
||||||
* If we fail to change ownership and if we are
|
* If we fail to change ownership and if we are
|
||||||
* using security model none. Ignore the error
|
* using security model none. Ignore the error
|
||||||
|
@ -110,9 +114,10 @@ static ssize_t local_readlink(FsContext *fs_ctx, const char *path,
|
||||||
char *buf, size_t bufsz)
|
char *buf, size_t bufsz)
|
||||||
{
|
{
|
||||||
ssize_t tsize = -1;
|
ssize_t tsize = -1;
|
||||||
|
char buffer[PATH_MAX];
|
||||||
if (fs_ctx->fs_sm == SM_MAPPED) {
|
if (fs_ctx->fs_sm == SM_MAPPED) {
|
||||||
int fd;
|
int fd;
|
||||||
fd = open(rpath(fs_ctx, path), O_RDONLY);
|
fd = open(rpath(fs_ctx, path, buffer), O_RDONLY);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -123,7 +128,7 @@ static ssize_t local_readlink(FsContext *fs_ctx, const char *path,
|
||||||
return tsize;
|
return tsize;
|
||||||
} else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
|
} else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
|
||||||
(fs_ctx->fs_sm == SM_NONE)) {
|
(fs_ctx->fs_sm == SM_NONE)) {
|
||||||
tsize = readlink(rpath(fs_ctx, path), buf, bufsz);
|
tsize = readlink(rpath(fs_ctx, path, buffer), buf, bufsz);
|
||||||
}
|
}
|
||||||
return tsize;
|
return tsize;
|
||||||
}
|
}
|
||||||
|
@ -140,12 +145,14 @@ static int local_closedir(FsContext *ctx, DIR *dir)
|
||||||
|
|
||||||
static int local_open(FsContext *ctx, const char *path, int flags)
|
static int local_open(FsContext *ctx, const char *path, int flags)
|
||||||
{
|
{
|
||||||
return open(rpath(ctx, path), flags);
|
char buffer[PATH_MAX];
|
||||||
|
return open(rpath(ctx, path, buffer), flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static DIR *local_opendir(FsContext *ctx, const char *path)
|
static DIR *local_opendir(FsContext *ctx, const char *path)
|
||||||
{
|
{
|
||||||
return opendir(rpath(ctx, path));
|
char buffer[PATH_MAX];
|
||||||
|
return opendir(rpath(ctx, path, buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void local_rewinddir(FsContext *ctx, DIR *dir)
|
static void local_rewinddir(FsContext *ctx, DIR *dir)
|
||||||
|
@ -200,11 +207,12 @@ static ssize_t local_pwritev(FsContext *ctx, int fd, const struct iovec *iov,
|
||||||
|
|
||||||
static int local_chmod(FsContext *fs_ctx, const char *path, FsCred *credp)
|
static int local_chmod(FsContext *fs_ctx, const char *path, FsCred *credp)
|
||||||
{
|
{
|
||||||
|
char buffer[PATH_MAX];
|
||||||
if (fs_ctx->fs_sm == SM_MAPPED) {
|
if (fs_ctx->fs_sm == SM_MAPPED) {
|
||||||
return local_set_xattr(rpath(fs_ctx, path), credp);
|
return local_set_xattr(rpath(fs_ctx, path, buffer), credp);
|
||||||
} else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
|
} else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
|
||||||
(fs_ctx->fs_sm == SM_NONE)) {
|
(fs_ctx->fs_sm == SM_NONE)) {
|
||||||
return chmod(rpath(fs_ctx, path), credp->fc_mode);
|
return chmod(rpath(fs_ctx, path, buffer), credp->fc_mode);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -213,21 +221,24 @@ static int local_mknod(FsContext *fs_ctx, const char *path, FsCred *credp)
|
||||||
{
|
{
|
||||||
int err = -1;
|
int err = -1;
|
||||||
int serrno = 0;
|
int serrno = 0;
|
||||||
|
char buffer[PATH_MAX];
|
||||||
|
|
||||||
/* Determine the security model */
|
/* Determine the security model */
|
||||||
if (fs_ctx->fs_sm == SM_MAPPED) {
|
if (fs_ctx->fs_sm == SM_MAPPED) {
|
||||||
err = mknod(rpath(fs_ctx, path), SM_LOCAL_MODE_BITS|S_IFREG, 0);
|
err = mknod(rpath(fs_ctx, path, buffer),
|
||||||
|
SM_LOCAL_MODE_BITS|S_IFREG, 0);
|
||||||
if (err == -1) {
|
if (err == -1) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
local_set_xattr(rpath(fs_ctx, path), credp);
|
local_set_xattr(rpath(fs_ctx, path, buffer), credp);
|
||||||
if (err == -1) {
|
if (err == -1) {
|
||||||
serrno = errno;
|
serrno = errno;
|
||||||
goto err_end;
|
goto err_end;
|
||||||
}
|
}
|
||||||
} else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
|
} else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
|
||||||
(fs_ctx->fs_sm == SM_NONE)) {
|
(fs_ctx->fs_sm == SM_NONE)) {
|
||||||
err = mknod(rpath(fs_ctx, path), credp->fc_mode, credp->fc_rdev);
|
err = mknod(rpath(fs_ctx, path, buffer), credp->fc_mode,
|
||||||
|
credp->fc_rdev);
|
||||||
if (err == -1) {
|
if (err == -1) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -240,7 +251,7 @@ static int local_mknod(FsContext *fs_ctx, const char *path, FsCred *credp)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
err_end:
|
err_end:
|
||||||
remove(rpath(fs_ctx, path));
|
remove(rpath(fs_ctx, path, buffer));
|
||||||
errno = serrno;
|
errno = serrno;
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -249,22 +260,23 @@ static int local_mkdir(FsContext *fs_ctx, const char *path, FsCred *credp)
|
||||||
{
|
{
|
||||||
int err = -1;
|
int err = -1;
|
||||||
int serrno = 0;
|
int serrno = 0;
|
||||||
|
char buffer[PATH_MAX];
|
||||||
|
|
||||||
/* Determine the security model */
|
/* Determine the security model */
|
||||||
if (fs_ctx->fs_sm == SM_MAPPED) {
|
if (fs_ctx->fs_sm == SM_MAPPED) {
|
||||||
err = mkdir(rpath(fs_ctx, path), SM_LOCAL_DIR_MODE_BITS);
|
err = mkdir(rpath(fs_ctx, path, buffer), SM_LOCAL_DIR_MODE_BITS);
|
||||||
if (err == -1) {
|
if (err == -1) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
credp->fc_mode = credp->fc_mode|S_IFDIR;
|
credp->fc_mode = credp->fc_mode|S_IFDIR;
|
||||||
err = local_set_xattr(rpath(fs_ctx, path), credp);
|
err = local_set_xattr(rpath(fs_ctx, path, buffer), credp);
|
||||||
if (err == -1) {
|
if (err == -1) {
|
||||||
serrno = errno;
|
serrno = errno;
|
||||||
goto err_end;
|
goto err_end;
|
||||||
}
|
}
|
||||||
} else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
|
} else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
|
||||||
(fs_ctx->fs_sm == SM_NONE)) {
|
(fs_ctx->fs_sm == SM_NONE)) {
|
||||||
err = mkdir(rpath(fs_ctx, path), credp->fc_mode);
|
err = mkdir(rpath(fs_ctx, path, buffer), credp->fc_mode);
|
||||||
if (err == -1) {
|
if (err == -1) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -277,7 +289,7 @@ static int local_mkdir(FsContext *fs_ctx, const char *path, FsCred *credp)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
err_end:
|
err_end:
|
||||||
remove(rpath(fs_ctx, path));
|
remove(rpath(fs_ctx, path, buffer));
|
||||||
errno = serrno;
|
errno = serrno;
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -318,23 +330,24 @@ static int local_open2(FsContext *fs_ctx, const char *path, int flags,
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
int err = -1;
|
int err = -1;
|
||||||
int serrno = 0;
|
int serrno = 0;
|
||||||
|
char buffer[PATH_MAX];
|
||||||
|
|
||||||
/* Determine the security model */
|
/* Determine the security model */
|
||||||
if (fs_ctx->fs_sm == SM_MAPPED) {
|
if (fs_ctx->fs_sm == SM_MAPPED) {
|
||||||
fd = open(rpath(fs_ctx, path), flags, SM_LOCAL_MODE_BITS);
|
fd = open(rpath(fs_ctx, path, buffer), flags, SM_LOCAL_MODE_BITS);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
credp->fc_mode = credp->fc_mode|S_IFREG;
|
credp->fc_mode = credp->fc_mode|S_IFREG;
|
||||||
/* Set cleint credentials in xattr */
|
/* Set cleint credentials in xattr */
|
||||||
err = local_set_xattr(rpath(fs_ctx, path), credp);
|
err = local_set_xattr(rpath(fs_ctx, path, buffer), credp);
|
||||||
if (err == -1) {
|
if (err == -1) {
|
||||||
serrno = errno;
|
serrno = errno;
|
||||||
goto err_end;
|
goto err_end;
|
||||||
}
|
}
|
||||||
} else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
|
} else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
|
||||||
(fs_ctx->fs_sm == SM_NONE)) {
|
(fs_ctx->fs_sm == SM_NONE)) {
|
||||||
fd = open(rpath(fs_ctx, path), flags, credp->fc_mode);
|
fd = open(rpath(fs_ctx, path, buffer), flags, credp->fc_mode);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
@ -348,7 +361,7 @@ static int local_open2(FsContext *fs_ctx, const char *path, int flags,
|
||||||
|
|
||||||
err_end:
|
err_end:
|
||||||
close(fd);
|
close(fd);
|
||||||
remove(rpath(fs_ctx, path));
|
remove(rpath(fs_ctx, path, buffer));
|
||||||
errno = serrno;
|
errno = serrno;
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -359,12 +372,13 @@ static int local_symlink(FsContext *fs_ctx, const char *oldpath,
|
||||||
{
|
{
|
||||||
int err = -1;
|
int err = -1;
|
||||||
int serrno = 0;
|
int serrno = 0;
|
||||||
|
char buffer[PATH_MAX];
|
||||||
|
|
||||||
/* Determine the security model */
|
/* Determine the security model */
|
||||||
if (fs_ctx->fs_sm == SM_MAPPED) {
|
if (fs_ctx->fs_sm == SM_MAPPED) {
|
||||||
int fd;
|
int fd;
|
||||||
ssize_t oldpath_size, write_size;
|
ssize_t oldpath_size, write_size;
|
||||||
fd = open(rpath(fs_ctx, newpath), O_CREAT|O_EXCL|O_RDWR,
|
fd = open(rpath(fs_ctx, newpath, buffer), O_CREAT|O_EXCL|O_RDWR,
|
||||||
SM_LOCAL_MODE_BITS);
|
SM_LOCAL_MODE_BITS);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
return fd;
|
return fd;
|
||||||
|
@ -384,18 +398,19 @@ static int local_symlink(FsContext *fs_ctx, const char *oldpath,
|
||||||
close(fd);
|
close(fd);
|
||||||
/* Set cleint credentials in symlink's xattr */
|
/* Set cleint credentials in symlink's xattr */
|
||||||
credp->fc_mode = credp->fc_mode|S_IFLNK;
|
credp->fc_mode = credp->fc_mode|S_IFLNK;
|
||||||
err = local_set_xattr(rpath(fs_ctx, newpath), credp);
|
err = local_set_xattr(rpath(fs_ctx, newpath, buffer), credp);
|
||||||
if (err == -1) {
|
if (err == -1) {
|
||||||
serrno = errno;
|
serrno = errno;
|
||||||
goto err_end;
|
goto err_end;
|
||||||
}
|
}
|
||||||
} else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
|
} else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
|
||||||
(fs_ctx->fs_sm == SM_NONE)) {
|
(fs_ctx->fs_sm == SM_NONE)) {
|
||||||
err = symlink(oldpath, rpath(fs_ctx, newpath));
|
err = symlink(oldpath, rpath(fs_ctx, newpath, buffer));
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
err = lchown(rpath(fs_ctx, newpath), credp->fc_uid, credp->fc_gid);
|
err = lchown(rpath(fs_ctx, newpath, buffer), credp->fc_uid,
|
||||||
|
credp->fc_gid);
|
||||||
if (err == -1) {
|
if (err == -1) {
|
||||||
/*
|
/*
|
||||||
* If we fail to change ownership and if we are
|
* If we fail to change ownership and if we are
|
||||||
|
@ -411,70 +426,45 @@ static int local_symlink(FsContext *fs_ctx, const char *oldpath,
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
err_end:
|
err_end:
|
||||||
remove(rpath(fs_ctx, newpath));
|
remove(rpath(fs_ctx, newpath, buffer));
|
||||||
errno = serrno;
|
errno = serrno;
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int local_link(FsContext *ctx, const char *oldpath, const char *newpath)
|
static int local_link(FsContext *ctx, const char *oldpath, const char *newpath)
|
||||||
{
|
{
|
||||||
char *tmp = qemu_strdup(rpath(ctx, oldpath));
|
char buffer[PATH_MAX], buffer1[PATH_MAX];
|
||||||
int err, serrno = 0;
|
|
||||||
|
|
||||||
if (tmp == NULL) {
|
return link(rpath(ctx, oldpath, buffer), rpath(ctx, newpath, buffer1));
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = link(tmp, rpath(ctx, newpath));
|
|
||||||
if (err == -1) {
|
|
||||||
serrno = errno;
|
|
||||||
}
|
|
||||||
|
|
||||||
qemu_free(tmp);
|
|
||||||
|
|
||||||
if (err == -1) {
|
|
||||||
errno = serrno;
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int local_truncate(FsContext *ctx, const char *path, off_t size)
|
static int local_truncate(FsContext *ctx, const char *path, off_t size)
|
||||||
{
|
{
|
||||||
return truncate(rpath(ctx, path), size);
|
char buffer[PATH_MAX];
|
||||||
|
return truncate(rpath(ctx, path, buffer), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int local_rename(FsContext *ctx, const char *oldpath,
|
static int local_rename(FsContext *ctx, const char *oldpath,
|
||||||
const char *newpath)
|
const char *newpath)
|
||||||
{
|
{
|
||||||
char *tmp;
|
char buffer[PATH_MAX], buffer1[PATH_MAX];
|
||||||
int err;
|
|
||||||
|
|
||||||
tmp = qemu_strdup(rpath(ctx, oldpath));
|
|
||||||
|
|
||||||
err = rename(tmp, rpath(ctx, newpath));
|
|
||||||
if (err == -1) {
|
|
||||||
int serrno = errno;
|
|
||||||
qemu_free(tmp);
|
|
||||||
errno = serrno;
|
|
||||||
} else {
|
|
||||||
qemu_free(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
|
||||||
|
|
||||||
|
return rename(rpath(ctx, oldpath, buffer), rpath(ctx, newpath, buffer1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int local_chown(FsContext *fs_ctx, const char *path, FsCred *credp)
|
static int local_chown(FsContext *fs_ctx, const char *path, FsCred *credp)
|
||||||
{
|
{
|
||||||
|
char buffer[PATH_MAX];
|
||||||
if ((credp->fc_uid == -1 && credp->fc_gid == -1) ||
|
if ((credp->fc_uid == -1 && credp->fc_gid == -1) ||
|
||||||
(fs_ctx->fs_sm == SM_PASSTHROUGH)) {
|
(fs_ctx->fs_sm == SM_PASSTHROUGH)) {
|
||||||
return lchown(rpath(fs_ctx, path), credp->fc_uid, credp->fc_gid);
|
return lchown(rpath(fs_ctx, path, buffer), credp->fc_uid,
|
||||||
|
credp->fc_gid);
|
||||||
} else if (fs_ctx->fs_sm == SM_MAPPED) {
|
} else if (fs_ctx->fs_sm == SM_MAPPED) {
|
||||||
return local_set_xattr(rpath(fs_ctx, path), credp);
|
return local_set_xattr(rpath(fs_ctx, path, buffer), credp);
|
||||||
} else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
|
} else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
|
||||||
(fs_ctx->fs_sm == SM_NONE)) {
|
(fs_ctx->fs_sm == SM_NONE)) {
|
||||||
return lchown(rpath(fs_ctx, path), credp->fc_uid, credp->fc_gid);
|
return lchown(rpath(fs_ctx, path, buffer), credp->fc_uid,
|
||||||
|
credp->fc_gid);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -482,12 +472,15 @@ static int local_chown(FsContext *fs_ctx, const char *path, FsCred *credp)
|
||||||
static int local_utimensat(FsContext *s, const char *path,
|
static int local_utimensat(FsContext *s, const char *path,
|
||||||
const struct timespec *buf)
|
const struct timespec *buf)
|
||||||
{
|
{
|
||||||
return qemu_utimensat(AT_FDCWD, rpath(s, path), buf, AT_SYMLINK_NOFOLLOW);
|
char buffer[PATH_MAX];
|
||||||
|
return qemu_utimensat(AT_FDCWD, rpath(s, path, buffer), buf,
|
||||||
|
AT_SYMLINK_NOFOLLOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int local_remove(FsContext *ctx, const char *path)
|
static int local_remove(FsContext *ctx, const char *path)
|
||||||
{
|
{
|
||||||
return remove(rpath(ctx, path));
|
char buffer[PATH_MAX];
|
||||||
|
return remove(rpath(ctx, path, buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int local_fsync(FsContext *ctx, int fd, int datasync)
|
static int local_fsync(FsContext *ctx, int fd, int datasync)
|
||||||
|
@ -501,7 +494,8 @@ static int local_fsync(FsContext *ctx, int fd, int datasync)
|
||||||
|
|
||||||
static int local_statfs(FsContext *s, const char *path, struct statfs *stbuf)
|
static int local_statfs(FsContext *s, const char *path, struct statfs *stbuf)
|
||||||
{
|
{
|
||||||
return statfs(rpath(s, path), stbuf);
|
char buffer[PATH_MAX];
|
||||||
|
return statfs(rpath(s, path, buffer), stbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t local_lgetxattr(FsContext *ctx, const char *path,
|
static ssize_t local_lgetxattr(FsContext *ctx, const char *path,
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <attr/xattr.h>
|
#include <attr/xattr.h>
|
||||||
#include "virtio.h"
|
#include "hw/virtio.h"
|
||||||
#include "virtio-9p.h"
|
#include "virtio-9p.h"
|
||||||
#include "fsdev/file-op-9p.h"
|
#include "fsdev/file-op-9p.h"
|
||||||
#include "virtio-9p-xattr.h"
|
#include "virtio-9p-xattr.h"
|
||||||
|
@ -26,7 +26,8 @@
|
||||||
static ssize_t mp_pacl_getxattr(FsContext *ctx, const char *path,
|
static ssize_t mp_pacl_getxattr(FsContext *ctx, const char *path,
|
||||||
const char *name, void *value, size_t size)
|
const char *name, void *value, size_t size)
|
||||||
{
|
{
|
||||||
return lgetxattr(rpath(ctx, path), MAP_ACL_ACCESS, value, size);
|
char buffer[PATH_MAX];
|
||||||
|
return lgetxattr(rpath(ctx, path, buffer), MAP_ACL_ACCESS, value, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t mp_pacl_listxattr(FsContext *ctx, const char *path,
|
static ssize_t mp_pacl_listxattr(FsContext *ctx, const char *path,
|
||||||
|
@ -50,14 +51,17 @@ static ssize_t mp_pacl_listxattr(FsContext *ctx, const char *path,
|
||||||
static int mp_pacl_setxattr(FsContext *ctx, const char *path, const char *name,
|
static int mp_pacl_setxattr(FsContext *ctx, const char *path, const char *name,
|
||||||
void *value, size_t size, int flags)
|
void *value, size_t size, int flags)
|
||||||
{
|
{
|
||||||
return lsetxattr(rpath(ctx, path), MAP_ACL_ACCESS, value, size, flags);
|
char buffer[PATH_MAX];
|
||||||
|
return lsetxattr(rpath(ctx, path, buffer), MAP_ACL_ACCESS, value,
|
||||||
|
size, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mp_pacl_removexattr(FsContext *ctx,
|
static int mp_pacl_removexattr(FsContext *ctx,
|
||||||
const char *path, const char *name)
|
const char *path, const char *name)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
ret = lremovexattr(rpath(ctx, path), MAP_ACL_ACCESS);
|
char buffer[PATH_MAX];
|
||||||
|
ret = lremovexattr(rpath(ctx, path, buffer), MAP_ACL_ACCESS);
|
||||||
if (ret == -1 && errno == ENODATA) {
|
if (ret == -1 && errno == ENODATA) {
|
||||||
/*
|
/*
|
||||||
* We don't get ENODATA error when trying to remove a
|
* We don't get ENODATA error when trying to remove a
|
||||||
|
@ -73,7 +77,8 @@ static int mp_pacl_removexattr(FsContext *ctx,
|
||||||
static ssize_t mp_dacl_getxattr(FsContext *ctx, const char *path,
|
static ssize_t mp_dacl_getxattr(FsContext *ctx, const char *path,
|
||||||
const char *name, void *value, size_t size)
|
const char *name, void *value, size_t size)
|
||||||
{
|
{
|
||||||
return lgetxattr(rpath(ctx, path), MAP_ACL_DEFAULT, value, size);
|
char buffer[PATH_MAX];
|
||||||
|
return lgetxattr(rpath(ctx, path, buffer), MAP_ACL_DEFAULT, value, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t mp_dacl_listxattr(FsContext *ctx, const char *path,
|
static ssize_t mp_dacl_listxattr(FsContext *ctx, const char *path,
|
||||||
|
@ -97,14 +102,17 @@ static ssize_t mp_dacl_listxattr(FsContext *ctx, const char *path,
|
||||||
static int mp_dacl_setxattr(FsContext *ctx, const char *path, const char *name,
|
static int mp_dacl_setxattr(FsContext *ctx, const char *path, const char *name,
|
||||||
void *value, size_t size, int flags)
|
void *value, size_t size, int flags)
|
||||||
{
|
{
|
||||||
return lsetxattr(rpath(ctx, path), MAP_ACL_DEFAULT, value, size, flags);
|
char buffer[PATH_MAX];
|
||||||
|
return lsetxattr(rpath(ctx, path, buffer), MAP_ACL_DEFAULT, value,
|
||||||
|
size, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mp_dacl_removexattr(FsContext *ctx,
|
static int mp_dacl_removexattr(FsContext *ctx,
|
||||||
const char *path, const char *name)
|
const char *path, const char *name)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
ret = lremovexattr(rpath(ctx, path), MAP_ACL_DEFAULT);
|
char buffer[PATH_MAX];
|
||||||
|
ret = lremovexattr(rpath(ctx, path, buffer), MAP_ACL_DEFAULT);
|
||||||
if (ret == -1 && errno == ENODATA) {
|
if (ret == -1 && errno == ENODATA) {
|
||||||
/*
|
/*
|
||||||
* We don't get ENODATA error when trying to remove a
|
* We don't get ENODATA error when trying to remove a
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include "virtio.h"
|
#include "hw/virtio.h"
|
||||||
#include "virtio-9p.h"
|
#include "virtio-9p.h"
|
||||||
#include "fsdev/file-op-9p.h"
|
#include "fsdev/file-op-9p.h"
|
||||||
#include "virtio-9p-xattr.h"
|
#include "virtio-9p-xattr.h"
|
||||||
|
@ -21,6 +21,7 @@
|
||||||
static ssize_t mp_user_getxattr(FsContext *ctx, const char *path,
|
static ssize_t mp_user_getxattr(FsContext *ctx, const char *path,
|
||||||
const char *name, void *value, size_t size)
|
const char *name, void *value, size_t size)
|
||||||
{
|
{
|
||||||
|
char buffer[PATH_MAX];
|
||||||
if (strncmp(name, "user.virtfs.", 12) == 0) {
|
if (strncmp(name, "user.virtfs.", 12) == 0) {
|
||||||
/*
|
/*
|
||||||
* Don't allow fetch of user.virtfs namesapce
|
* Don't allow fetch of user.virtfs namesapce
|
||||||
|
@ -29,7 +30,7 @@ static ssize_t mp_user_getxattr(FsContext *ctx, const char *path,
|
||||||
errno = ENOATTR;
|
errno = ENOATTR;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return lgetxattr(rpath(ctx, path), name, value, size);
|
return lgetxattr(rpath(ctx, path, buffer), name, value, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t mp_user_listxattr(FsContext *ctx, const char *path,
|
static ssize_t mp_user_listxattr(FsContext *ctx, const char *path,
|
||||||
|
@ -67,6 +68,7 @@ static ssize_t mp_user_listxattr(FsContext *ctx, const char *path,
|
||||||
static int mp_user_setxattr(FsContext *ctx, const char *path, const char *name,
|
static int mp_user_setxattr(FsContext *ctx, const char *path, const char *name,
|
||||||
void *value, size_t size, int flags)
|
void *value, size_t size, int flags)
|
||||||
{
|
{
|
||||||
|
char buffer[PATH_MAX];
|
||||||
if (strncmp(name, "user.virtfs.", 12) == 0) {
|
if (strncmp(name, "user.virtfs.", 12) == 0) {
|
||||||
/*
|
/*
|
||||||
* Don't allow fetch of user.virtfs namesapce
|
* Don't allow fetch of user.virtfs namesapce
|
||||||
|
@ -75,12 +77,13 @@ static int mp_user_setxattr(FsContext *ctx, const char *path, const char *name,
|
||||||
errno = EACCES;
|
errno = EACCES;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return lsetxattr(rpath(ctx, path), name, value, size, flags);
|
return lsetxattr(rpath(ctx, path, buffer), name, value, size, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mp_user_removexattr(FsContext *ctx,
|
static int mp_user_removexattr(FsContext *ctx,
|
||||||
const char *path, const char *name)
|
const char *path, const char *name)
|
||||||
{
|
{
|
||||||
|
char buffer[PATH_MAX];
|
||||||
if (strncmp(name, "user.virtfs.", 12) == 0) {
|
if (strncmp(name, "user.virtfs.", 12) == 0) {
|
||||||
/*
|
/*
|
||||||
* Don't allow fetch of user.virtfs namesapce
|
* Don't allow fetch of user.virtfs namesapce
|
||||||
|
@ -89,7 +92,7 @@ static int mp_user_removexattr(FsContext *ctx,
|
||||||
errno = EACCES;
|
errno = EACCES;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return lremovexattr(rpath(ctx, path), name);
|
return lremovexattr(rpath(ctx, path, buffer), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
XattrOperations mapped_user_xattr = {
|
XattrOperations mapped_user_xattr = {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "virtio.h"
|
#include "hw/virtio.h"
|
||||||
#include "virtio-9p.h"
|
#include "virtio-9p.h"
|
||||||
#include "fsdev/file-op-9p.h"
|
#include "fsdev/file-op-9p.h"
|
||||||
#include "virtio-9p-xattr.h"
|
#include "virtio-9p-xattr.h"
|
||||||
|
@ -66,20 +66,21 @@ ssize_t v9fs_list_xattr(FsContext *ctx, const char *path,
|
||||||
void *value, size_t vsize)
|
void *value, size_t vsize)
|
||||||
{
|
{
|
||||||
ssize_t size = 0;
|
ssize_t size = 0;
|
||||||
|
char buffer[PATH_MAX];
|
||||||
void *ovalue = value;
|
void *ovalue = value;
|
||||||
XattrOperations *xops;
|
XattrOperations *xops;
|
||||||
char *orig_value, *orig_value_start;
|
char *orig_value, *orig_value_start;
|
||||||
ssize_t xattr_len, parsed_len = 0, attr_len;
|
ssize_t xattr_len, parsed_len = 0, attr_len;
|
||||||
|
|
||||||
/* Get the actual len */
|
/* Get the actual len */
|
||||||
xattr_len = llistxattr(rpath(ctx, path), value, 0);
|
xattr_len = llistxattr(rpath(ctx, path, buffer), value, 0);
|
||||||
if (xattr_len <= 0) {
|
if (xattr_len <= 0) {
|
||||||
return xattr_len;
|
return xattr_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now fetch the xattr and find the actual size */
|
/* Now fetch the xattr and find the actual size */
|
||||||
orig_value = qemu_malloc(xattr_len);
|
orig_value = qemu_malloc(xattr_len);
|
||||||
xattr_len = llistxattr(rpath(ctx, path), orig_value, xattr_len);
|
xattr_len = llistxattr(rpath(ctx, path, buffer), orig_value, xattr_len);
|
||||||
|
|
||||||
/* store the orig pointer */
|
/* store the orig pointer */
|
||||||
orig_value_start = orig_value;
|
orig_value_start = orig_value;
|
||||||
|
|
|
@ -54,20 +54,23 @@ ssize_t pt_listxattr(FsContext *ctx, const char *path, char *name, void *value,
|
||||||
static inline ssize_t pt_getxattr(FsContext *ctx, const char *path,
|
static inline ssize_t pt_getxattr(FsContext *ctx, const char *path,
|
||||||
const char *name, void *value, size_t size)
|
const char *name, void *value, size_t size)
|
||||||
{
|
{
|
||||||
return lgetxattr(rpath(ctx, path), name, value, size);
|
char buffer[PATH_MAX];
|
||||||
|
return lgetxattr(rpath(ctx, path, buffer), name, value, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int pt_setxattr(FsContext *ctx, const char *path,
|
static inline int pt_setxattr(FsContext *ctx, const char *path,
|
||||||
const char *name, void *value,
|
const char *name, void *value,
|
||||||
size_t size, int flags)
|
size_t size, int flags)
|
||||||
{
|
{
|
||||||
return lsetxattr(rpath(ctx, path), name, value, size, flags);
|
char buffer[PATH_MAX];
|
||||||
|
return lsetxattr(rpath(ctx, path, buffer), name, value, size, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int pt_removexattr(FsContext *ctx,
|
static inline int pt_removexattr(FsContext *ctx,
|
||||||
const char *path, const char *name)
|
const char *path, const char *name)
|
||||||
{
|
{
|
||||||
return lremovexattr(rpath(ctx, path), name);
|
char buffer[PATH_MAX];
|
||||||
|
return lremovexattr(rpath(ctx, path, buffer), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline ssize_t notsup_getxattr(FsContext *ctx, const char *path,
|
static inline ssize_t notsup_getxattr(FsContext *ctx, const char *path,
|
||||||
|
|
|
@ -11,9 +11,10 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "virtio.h"
|
#include "hw/virtio.h"
|
||||||
#include "pc.h"
|
#include "hw/pc.h"
|
||||||
#include "qemu_socket.h"
|
#include "qemu_socket.h"
|
||||||
|
#include "hw/virtio-pci.h"
|
||||||
#include "virtio-9p.h"
|
#include "virtio-9p.h"
|
||||||
#include "fsdev/qemu-fsdev.h"
|
#include "fsdev/qemu-fsdev.h"
|
||||||
#include "virtio-9p-debug.h"
|
#include "virtio-9p-debug.h"
|
||||||
|
@ -422,6 +423,22 @@ static void v9fs_string_copy(V9fsString *lhs, V9fsString *rhs)
|
||||||
v9fs_string_sprintf(lhs, "%s", rhs->data);
|
v9fs_string_sprintf(lhs, "%s", rhs->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return TRUE if s1 is an ancestor of s2.
|
||||||
|
*
|
||||||
|
* E.g. "a/b" is an ancestor of "a/b/c" but not of "a/bc/d".
|
||||||
|
* As a special case, We treat s1 as ancestor of s2 if they are same!
|
||||||
|
*/
|
||||||
|
static int v9fs_path_is_ancestor(V9fsString *s1, V9fsString *s2)
|
||||||
|
{
|
||||||
|
if (!strncmp(s1->data, s2->data, s1->size)) {
|
||||||
|
if (s2->data[s1->size] == '\0' || s2->data[s1->size] == '/') {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static size_t v9fs_string_size(V9fsString *str)
|
static size_t v9fs_string_size(V9fsString *str)
|
||||||
{
|
{
|
||||||
return str->size;
|
return str->size;
|
||||||
|
@ -2804,13 +2821,13 @@ static int v9fs_complete_rename(V9fsState *s, V9fsRenameState *vs)
|
||||||
for (fidp = s->fid_list; fidp; fidp = fidp->next) {
|
for (fidp = s->fid_list; fidp; fidp = fidp->next) {
|
||||||
if (vs->fidp == fidp) {
|
if (vs->fidp == fidp) {
|
||||||
/*
|
/*
|
||||||
* we replace name of this fid towards the end
|
* we replace name of this fid towards the end so
|
||||||
* so that our below strcmp will work
|
* that our below v9fs_path_is_ancestor check will
|
||||||
|
* work
|
||||||
*/
|
*/
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strncmp(vs->fidp->path.data, fidp->path.data,
|
if (v9fs_path_is_ancestor(&vs->fidp->path, &fidp->path)) {
|
||||||
strlen(vs->fidp->path.data))) {
|
|
||||||
/* replace the name */
|
/* replace the name */
|
||||||
v9fs_fix_path(&fidp->path, &vs->name,
|
v9fs_fix_path(&fidp->path, &vs->name,
|
||||||
strlen(vs->fidp->path.data));
|
strlen(vs->fidp->path.data));
|
||||||
|
@ -3588,6 +3605,11 @@ static pdu_handler_t *pdu_handlers[] = {
|
||||||
[P9_TREMOVE] = v9fs_remove,
|
[P9_TREMOVE] = v9fs_remove,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void v9fs_op_not_supp(V9fsState *s, V9fsPDU *pdu)
|
||||||
|
{
|
||||||
|
complete_pdu(s, pdu, -EOPNOTSUPP);
|
||||||
|
}
|
||||||
|
|
||||||
static void submit_pdu(V9fsState *s, V9fsPDU *pdu)
|
static void submit_pdu(V9fsState *s, V9fsPDU *pdu)
|
||||||
{
|
{
|
||||||
pdu_handler_t *handler;
|
pdu_handler_t *handler;
|
||||||
|
@ -3595,16 +3617,16 @@ static void submit_pdu(V9fsState *s, V9fsPDU *pdu)
|
||||||
if (debug_9p_pdu) {
|
if (debug_9p_pdu) {
|
||||||
pprint_pdu(pdu);
|
pprint_pdu(pdu);
|
||||||
}
|
}
|
||||||
|
if (pdu->id >= ARRAY_SIZE(pdu_handlers) ||
|
||||||
BUG_ON(pdu->id >= ARRAY_SIZE(pdu_handlers));
|
(pdu_handlers[pdu->id] == NULL)) {
|
||||||
|
handler = v9fs_op_not_supp;
|
||||||
handler = pdu_handlers[pdu->id];
|
} else {
|
||||||
BUG_ON(handler == NULL);
|
handler = pdu_handlers[pdu->id];
|
||||||
|
}
|
||||||
handler(s, pdu);
|
handler(s, pdu);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq)
|
void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq)
|
||||||
{
|
{
|
||||||
V9fsState *s = (V9fsState *)vdev;
|
V9fsState *s = (V9fsState *)vdev;
|
||||||
V9fsPDU *pdu;
|
V9fsPDU *pdu;
|
||||||
|
@ -3628,119 +3650,3 @@ static void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq)
|
||||||
|
|
||||||
free_pdu(s, pdu);
|
free_pdu(s, pdu);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t virtio_9p_get_features(VirtIODevice *vdev, uint32_t features)
|
|
||||||
{
|
|
||||||
features |= 1 << VIRTIO_9P_MOUNT_TAG;
|
|
||||||
return features;
|
|
||||||
}
|
|
||||||
|
|
||||||
static V9fsState *to_virtio_9p(VirtIODevice *vdev)
|
|
||||||
{
|
|
||||||
return (V9fsState *)vdev;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config)
|
|
||||||
{
|
|
||||||
struct virtio_9p_config *cfg;
|
|
||||||
V9fsState *s = to_virtio_9p(vdev);
|
|
||||||
|
|
||||||
cfg = qemu_mallocz(sizeof(struct virtio_9p_config) +
|
|
||||||
s->tag_len);
|
|
||||||
stw_raw(&cfg->tag_len, s->tag_len);
|
|
||||||
memcpy(cfg->tag, s->tag, s->tag_len);
|
|
||||||
memcpy(config, cfg, s->config_size);
|
|
||||||
qemu_free(cfg);
|
|
||||||
}
|
|
||||||
|
|
||||||
VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
|
|
||||||
{
|
|
||||||
V9fsState *s;
|
|
||||||
int i, len;
|
|
||||||
struct stat stat;
|
|
||||||
FsTypeEntry *fse;
|
|
||||||
|
|
||||||
|
|
||||||
s = (V9fsState *)virtio_common_init("virtio-9p",
|
|
||||||
VIRTIO_ID_9P,
|
|
||||||
sizeof(struct virtio_9p_config)+
|
|
||||||
MAX_TAG_LEN,
|
|
||||||
sizeof(V9fsState));
|
|
||||||
|
|
||||||
/* initialize pdu allocator */
|
|
||||||
QLIST_INIT(&s->free_list);
|
|
||||||
for (i = 0; i < (MAX_REQ - 1); i++) {
|
|
||||||
QLIST_INSERT_HEAD(&s->free_list, &s->pdus[i], next);
|
|
||||||
}
|
|
||||||
|
|
||||||
s->vq = virtio_add_queue(&s->vdev, MAX_REQ, handle_9p_output);
|
|
||||||
|
|
||||||
fse = get_fsdev_fsentry(conf->fsdev_id);
|
|
||||||
|
|
||||||
if (!fse) {
|
|
||||||
/* We don't have a fsdev identified by fsdev_id */
|
|
||||||
fprintf(stderr, "Virtio-9p device couldn't find fsdev with the "
|
|
||||||
"id = %s\n", conf->fsdev_id ? conf->fsdev_id : "NULL");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fse->path || !conf->tag) {
|
|
||||||
/* we haven't specified a mount_tag or the path */
|
|
||||||
fprintf(stderr, "fsdev with id %s needs path "
|
|
||||||
"and Virtio-9p device needs mount_tag arguments\n",
|
|
||||||
conf->fsdev_id);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(fse->security_model, "passthrough")) {
|
|
||||||
/* Files on the Fileserver set to client user credentials */
|
|
||||||
s->ctx.fs_sm = SM_PASSTHROUGH;
|
|
||||||
s->ctx.xops = passthrough_xattr_ops;
|
|
||||||
} else if (!strcmp(fse->security_model, "mapped")) {
|
|
||||||
/* Files on the fileserver are set to QEMU credentials.
|
|
||||||
* Client user credentials are saved in extended attributes.
|
|
||||||
*/
|
|
||||||
s->ctx.fs_sm = SM_MAPPED;
|
|
||||||
s->ctx.xops = mapped_xattr_ops;
|
|
||||||
} else if (!strcmp(fse->security_model, "none")) {
|
|
||||||
/*
|
|
||||||
* Files on the fileserver are set to QEMU credentials.
|
|
||||||
*/
|
|
||||||
s->ctx.fs_sm = SM_NONE;
|
|
||||||
s->ctx.xops = none_xattr_ops;
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, "Default to security_model=none. You may want"
|
|
||||||
" enable advanced security model using "
|
|
||||||
"security option:\n\t security_model=passthrough \n\t "
|
|
||||||
"security_model=mapped\n");
|
|
||||||
s->ctx.fs_sm = SM_NONE;
|
|
||||||
s->ctx.xops = none_xattr_ops;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lstat(fse->path, &stat)) {
|
|
||||||
fprintf(stderr, "share path %s does not exist\n", fse->path);
|
|
||||||
exit(1);
|
|
||||||
} else if (!S_ISDIR(stat.st_mode)) {
|
|
||||||
fprintf(stderr, "share path %s is not a directory \n", fse->path);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
s->ctx.fs_root = qemu_strdup(fse->path);
|
|
||||||
len = strlen(conf->tag);
|
|
||||||
if (len > MAX_TAG_LEN) {
|
|
||||||
len = MAX_TAG_LEN;
|
|
||||||
}
|
|
||||||
/* s->tag is non-NULL terminated string */
|
|
||||||
s->tag = qemu_malloc(len);
|
|
||||||
memcpy(s->tag, conf->tag, len);
|
|
||||||
s->tag_len = len;
|
|
||||||
s->ctx.uid = -1;
|
|
||||||
|
|
||||||
s->ops = fse->ops;
|
|
||||||
s->vdev.get_features = virtio_9p_get_features;
|
|
||||||
s->config_size = sizeof(struct virtio_9p_config) +
|
|
||||||
s->tag_len;
|
|
||||||
s->vdev.get_config = virtio_9p_get_config;
|
|
||||||
|
|
||||||
return &s->vdev;
|
|
||||||
}
|
|
||||||
|
|
|
@ -101,6 +101,11 @@ enum p9_proto_version {
|
||||||
#define P9_NOTAG (u16)(~0)
|
#define P9_NOTAG (u16)(~0)
|
||||||
#define P9_NOFID (u32)(~0)
|
#define P9_NOFID (u32)(~0)
|
||||||
#define P9_MAXWELEM 16
|
#define P9_MAXWELEM 16
|
||||||
|
static inline const char *rpath(FsContext *ctx, const char *path, char *buffer)
|
||||||
|
{
|
||||||
|
snprintf(buffer, PATH_MAX, "%s/%s", ctx->fs_root, path);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ample room for Twrite/Rread header
|
* ample room for Twrite/Rread header
|
||||||
|
@ -504,4 +509,6 @@ static inline size_t do_pdu_unpack(void *dst, struct iovec *sg, int sg_count,
|
||||||
return pdu_packunpack(dst, sg, sg_count, offset, size, 0);
|
return pdu_packunpack(dst, sg, sg_count, offset, size, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "loader.h"
|
#include "loader.h"
|
||||||
#include "kvm.h"
|
#include "kvm.h"
|
||||||
#include "blockdev.h"
|
#include "blockdev.h"
|
||||||
|
#include "virtio-pci.h"
|
||||||
|
|
||||||
/* from Linux's linux/virtio_pci.h */
|
/* from Linux's linux/virtio_pci.h */
|
||||||
|
|
||||||
|
@ -95,27 +96,6 @@
|
||||||
*/
|
*/
|
||||||
#define wmb() do { } while (0)
|
#define wmb() do { } while (0)
|
||||||
|
|
||||||
/* PCI bindings. */
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
PCIDevice pci_dev;
|
|
||||||
VirtIODevice *vdev;
|
|
||||||
uint32_t flags;
|
|
||||||
uint32_t addr;
|
|
||||||
uint32_t class_code;
|
|
||||||
uint32_t nvectors;
|
|
||||||
BlockConf block;
|
|
||||||
NICConf nic;
|
|
||||||
uint32_t host_features;
|
|
||||||
#ifdef CONFIG_LINUX
|
|
||||||
V9fsConf fsconf;
|
|
||||||
#endif
|
|
||||||
virtio_serial_conf serial;
|
|
||||||
virtio_net_conf net;
|
|
||||||
bool ioeventfd_disabled;
|
|
||||||
bool ioeventfd_started;
|
|
||||||
} VirtIOPCIProxy;
|
|
||||||
|
|
||||||
/* virtio device */
|
/* virtio device */
|
||||||
|
|
||||||
static void virtio_pci_notify(void *opaque, uint16_t vector)
|
static void virtio_pci_notify(void *opaque, uint16_t vector)
|
||||||
|
@ -669,7 +649,7 @@ static const VirtIOBindings virtio_pci_bindings = {
|
||||||
.vmstate_change = virtio_pci_vmstate_change,
|
.vmstate_change = virtio_pci_vmstate_change,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
|
void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
|
||||||
uint16_t vendor, uint16_t device,
|
uint16_t vendor, uint16_t device,
|
||||||
uint16_t class_code, uint8_t pif)
|
uint16_t class_code, uint8_t pif)
|
||||||
{
|
{
|
||||||
|
@ -835,25 +815,6 @@ static int virtio_balloon_init_pci(PCIDevice *pci_dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_VIRTFS
|
|
||||||
static int virtio_9p_init_pci(PCIDevice *pci_dev)
|
|
||||||
{
|
|
||||||
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
|
|
||||||
VirtIODevice *vdev;
|
|
||||||
|
|
||||||
vdev = virtio_9p_init(&pci_dev->qdev, &proxy->fsconf);
|
|
||||||
vdev->nvectors = proxy->nvectors;
|
|
||||||
virtio_init_pci(proxy, vdev,
|
|
||||||
PCI_VENDOR_ID_REDHAT_QUMRANET,
|
|
||||||
0x1009,
|
|
||||||
0x2,
|
|
||||||
0x00);
|
|
||||||
/* make the actual value visible */
|
|
||||||
proxy->nvectors = vdev->nvectors;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static PCIDeviceInfo virtio_info[] = {
|
static PCIDeviceInfo virtio_info[] = {
|
||||||
{
|
{
|
||||||
.qdev.name = "virtio-blk-pci",
|
.qdev.name = "virtio-blk-pci",
|
||||||
|
@ -922,20 +883,6 @@ static PCIDeviceInfo virtio_info[] = {
|
||||||
},
|
},
|
||||||
.qdev.reset = virtio_pci_reset,
|
.qdev.reset = virtio_pci_reset,
|
||||||
},{
|
},{
|
||||||
#ifdef CONFIG_VIRTFS
|
|
||||||
.qdev.name = "virtio-9p-pci",
|
|
||||||
.qdev.alias = "virtio-9p",
|
|
||||||
.qdev.size = sizeof(VirtIOPCIProxy),
|
|
||||||
.init = virtio_9p_init_pci,
|
|
||||||
.qdev.props = (Property[]) {
|
|
||||||
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
|
|
||||||
DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),
|
|
||||||
DEFINE_PROP_STRING("mount_tag", VirtIOPCIProxy, fsconf.tag),
|
|
||||||
DEFINE_PROP_STRING("fsdev", VirtIOPCIProxy, fsconf.fsdev_id),
|
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
|
||||||
},
|
|
||||||
}, {
|
|
||||||
#endif
|
|
||||||
/* end of list */
|
/* end of list */
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* Virtio PCI Bindings
|
||||||
|
*
|
||||||
|
* Copyright IBM, Corp. 2007
|
||||||
|
* Copyright (c) 2009 CodeSourcery
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Anthony Liguori <aliguori@us.ibm.com>
|
||||||
|
* Paul Brook <paul@codesourcery.com>
|
||||||
|
*
|
||||||
|
* This work is licensed under the terms of the GNU GPL, version 2. See
|
||||||
|
* the COPYING file in the top-level directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef QEMU_VIRTIO_PCI_H
|
||||||
|
#define QEMU_VIRTIO_PCI_H
|
||||||
|
|
||||||
|
#include "virtio-net.h"
|
||||||
|
#include "virtio-serial.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
PCIDevice pci_dev;
|
||||||
|
VirtIODevice *vdev;
|
||||||
|
uint32_t flags;
|
||||||
|
uint32_t addr;
|
||||||
|
uint32_t class_code;
|
||||||
|
uint32_t nvectors;
|
||||||
|
BlockConf block;
|
||||||
|
NICConf nic;
|
||||||
|
uint32_t host_features;
|
||||||
|
#ifdef CONFIG_LINUX
|
||||||
|
V9fsConf fsconf;
|
||||||
|
#endif
|
||||||
|
virtio_serial_conf serial;
|
||||||
|
virtio_net_conf net;
|
||||||
|
bool ioeventfd_disabled;
|
||||||
|
bool ioeventfd_started;
|
||||||
|
} VirtIOPCIProxy;
|
||||||
|
|
||||||
|
extern void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
|
||||||
|
uint16_t vendor, uint16_t device,
|
||||||
|
uint16_t class_code, uint8_t pif);
|
||||||
|
#endif
|
Loading…
Reference in New Issue