mirror of
https://github.com/utmapp/qemu.git
synced 2026-12-04 16:12:57 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
386b2a5767 | ||
|
|
5c49f7ee3b | ||
|
|
b8fdfa9d63 | ||
|
|
ebf5b3946e | ||
|
|
f2fd6555c7 | ||
|
|
f243bb4b0d | ||
|
|
a575af07b8 | ||
|
|
5e817ece11 | ||
|
|
b57df52546 | ||
|
|
921352867b | ||
|
|
dcf682dd13 | ||
|
|
08550a9940 | ||
|
|
b52a91816e | ||
|
|
eca194d43c | ||
|
|
d8f0b2bbf4 | ||
|
|
58c523563d | ||
|
|
7c4c30e764 | ||
|
|
595c40575b | ||
|
|
6261aa4ff5 | ||
|
|
7eb63fccf4 | ||
|
|
67808fda37 | ||
|
|
c16fd8a2bb | ||
|
|
d2581f25ec | ||
|
|
42e9a42083 | ||
|
|
2f783fb459 | ||
|
|
d7fab184e9 | ||
|
|
c8966bff5f | ||
|
|
e569ca39fa | ||
|
|
6a34f7752f | ||
|
|
557980ba70 | ||
|
|
b6f4d5bf20 | ||
|
|
bc67d011c3 | ||
|
|
5bdcc0f3ed | ||
|
|
f756254e0a | ||
|
|
7b41093d14 | ||
|
|
acb988e20c | ||
|
|
3ddb01cd14 | ||
|
|
ad1169e23c | ||
|
|
a799013e71 | ||
|
|
54e74a45a5 | ||
|
|
9380cb9de2 | ||
|
|
b3e49baa79 | ||
|
|
558905635b | ||
|
|
b17b3c209b | ||
|
|
7a1f17a51e | ||
|
|
0aad2a5255 | ||
|
|
0fd3972e1c | ||
|
|
045849b078 | ||
|
|
974b857df6 | ||
|
|
782e94132a | ||
|
|
182be02962 | ||
|
|
b14cd263ad | ||
|
|
68d84b133d | ||
|
|
e399bb1bf1 | ||
|
|
160546b81e | ||
|
|
dcc935873b | ||
|
|
5145f2471c | ||
|
|
458ae56d22 | ||
|
|
521898ac31 | ||
|
|
c1abbd0f04 | ||
|
|
a637ea0c52 | ||
|
|
73a01bc9b0 | ||
|
|
d723a57acd | ||
|
|
dd506af071 | ||
|
|
387a3ac89d | ||
|
|
cb84d9d353 | ||
|
|
b38d9cada4 | ||
|
|
f56a86ad8d | ||
|
|
5bfdf41d7c | ||
|
|
e37ba5c637 | ||
|
|
4cc0a28a6e | ||
|
|
d1cba8ca60 | ||
|
|
945d9273c8 | ||
|
|
99458fbb56 | ||
|
|
d48973dc26 | ||
|
|
c6414cb183 | ||
|
|
250322bfbd | ||
|
|
bdac9aabd9 | ||
|
|
352259fef8 | ||
|
|
9e6e3ba309 |
No files matched your search
+4
-2
@@ -383,8 +383,10 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
|
||||
assert(sizeof(backend->host_nodes) >=
|
||||
BITS_TO_LONGS(MAX_NODES + 1) * sizeof(unsigned long));
|
||||
assert(maxnode <= MAX_NODES);
|
||||
if (mbind(ptr, sz, backend->policy,
|
||||
maxnode ? backend->host_nodes : NULL, maxnode + 1, flags)) {
|
||||
|
||||
if (maxnode &&
|
||||
mbind(ptr, sz, backend->policy, backend->host_nodes, maxnode + 1,
|
||||
flags)) {
|
||||
if (backend->policy != MPOL_DEFAULT || errno != ENOSYS) {
|
||||
error_setg_errno(errp, errno,
|
||||
"cannot bind memory to host NUMA nodes");
|
||||
|
||||
@@ -6710,8 +6710,11 @@ void bdrv_refresh_filename(BlockDriverState *bs)
|
||||
pstrcpy(bs->filename, sizeof(bs->filename), bs->exact_filename);
|
||||
} else {
|
||||
QString *json = qobject_to_json(QOBJECT(bs->full_open_options));
|
||||
snprintf(bs->filename, sizeof(bs->filename), "json:%s",
|
||||
qstring_get_str(json));
|
||||
if (snprintf(bs->filename, sizeof(bs->filename), "json:%s",
|
||||
qstring_get_str(json)) >= sizeof(bs->filename)) {
|
||||
/* Give user a hint if we truncated things. */
|
||||
strcpy(bs->filename + sizeof(bs->filename) - 4, "...");
|
||||
}
|
||||
qobject_unref(json);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-4
@@ -1501,12 +1501,13 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child,
|
||||
assert(num);
|
||||
|
||||
ret = bdrv_driver_preadv(bs, offset + bytes - bytes_remaining,
|
||||
num, qiov, bytes - bytes_remaining, 0);
|
||||
num, qiov,
|
||||
qiov_offset + bytes - bytes_remaining, 0);
|
||||
max_bytes -= num;
|
||||
} else {
|
||||
num = bytes_remaining;
|
||||
ret = qemu_iovec_memset(qiov, bytes - bytes_remaining, 0,
|
||||
bytes_remaining);
|
||||
ret = qemu_iovec_memset(qiov, qiov_offset + bytes - bytes_remaining,
|
||||
0, bytes_remaining);
|
||||
}
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
@@ -2009,7 +2010,8 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
|
||||
}
|
||||
|
||||
ret = bdrv_driver_pwritev(bs, offset + bytes - bytes_remaining,
|
||||
num, qiov, bytes - bytes_remaining,
|
||||
num, qiov,
|
||||
qiov_offset + bytes - bytes_remaining,
|
||||
local_flags);
|
||||
if (ret < 0) {
|
||||
break;
|
||||
|
||||
+13
-8
@@ -1986,6 +1986,7 @@ static void nbd_refresh_filename(BlockDriverState *bs)
|
||||
{
|
||||
BDRVNBDState *s = bs->opaque;
|
||||
const char *host = NULL, *port = NULL, *path = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
if (s->saddr->type == SOCKET_ADDRESS_TYPE_INET) {
|
||||
const InetSocketAddress *inet = &s->saddr->u.inet;
|
||||
@@ -1998,17 +1999,21 @@ static void nbd_refresh_filename(BlockDriverState *bs)
|
||||
} /* else can't represent as pseudo-filename */
|
||||
|
||||
if (path && s->export) {
|
||||
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
|
||||
"nbd+unix:///%s?socket=%s", s->export, path);
|
||||
len = snprintf(bs->exact_filename, sizeof(bs->exact_filename),
|
||||
"nbd+unix:///%s?socket=%s", s->export, path);
|
||||
} else if (path && !s->export) {
|
||||
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
|
||||
"nbd+unix://?socket=%s", path);
|
||||
len = snprintf(bs->exact_filename, sizeof(bs->exact_filename),
|
||||
"nbd+unix://?socket=%s", path);
|
||||
} else if (host && s->export) {
|
||||
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
|
||||
"nbd://%s:%s/%s", host, port, s->export);
|
||||
len = snprintf(bs->exact_filename, sizeof(bs->exact_filename),
|
||||
"nbd://%s:%s/%s", host, port, s->export);
|
||||
} else if (host && !s->export) {
|
||||
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
|
||||
"nbd://%s:%s", host, port);
|
||||
len = snprintf(bs->exact_filename, sizeof(bs->exact_filename),
|
||||
"nbd://%s:%s", host, port);
|
||||
}
|
||||
if (len >= sizeof(bs->exact_filename)) {
|
||||
/* Name is too long to represent exactly, so leave it empty. */
|
||||
bs->exact_filename[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -138,9 +138,12 @@ static void check_report_connect_error(Chardev *chr,
|
||||
SocketChardev *s = SOCKET_CHARDEV(chr);
|
||||
|
||||
if (!s->connect_err_reported) {
|
||||
error_report("Unable to connect character device %s: %s",
|
||||
chr->label, error_get_pretty(err));
|
||||
error_reportf_err(err,
|
||||
"Unable to connect character device %s: ",
|
||||
chr->label);
|
||||
s->connect_err_reported = true;
|
||||
} else {
|
||||
error_free(err);
|
||||
}
|
||||
qemu_chr_socket_restart_timer(chr);
|
||||
}
|
||||
@@ -1082,7 +1085,6 @@ static void qemu_chr_socket_connected(QIOTask *task, void *opaque)
|
||||
if (qio_task_propagate_error(task, &err)) {
|
||||
tcp_chr_change_state(s, TCP_CHARDEV_STATE_DISCONNECTED);
|
||||
check_report_connect_error(chr, err);
|
||||
error_free(err);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
||||
@@ -1867,7 +1867,7 @@ virtqueue_get_head(VuDev *dev, VuVirtq *vq,
|
||||
|
||||
/* If their number is silly, that's a fatal mistake. */
|
||||
if (*head >= vq->vring.num) {
|
||||
vu_panic(dev, "Guest says index %u is available", head);
|
||||
vu_panic(dev, "Guest says index %u is available", *head);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1926,7 +1926,7 @@ virtqueue_read_next_desc(VuDev *dev, struct vring_desc *desc,
|
||||
smp_wmb();
|
||||
|
||||
if (*next >= max) {
|
||||
vu_panic(dev, "Desc next is %u", next);
|
||||
vu_panic(dev, "Desc next is %u", *next);
|
||||
return VIRTQUEUE_READ_DESC_ERROR;
|
||||
}
|
||||
|
||||
|
||||
@@ -127,6 +127,16 @@ can be downloaded from:
|
||||
Alternatively, you can also choose to build you own image with buildroot
|
||||
using the orangepi_pc_defconfig. Also see https://buildroot.org for more information.
|
||||
|
||||
When using an image as an SD card, it must be resized to a power of two. This can be
|
||||
done with the qemu-img command. It is recommended to only increase the image size
|
||||
instead of shrinking it to a power of two, to avoid loss of data. For example,
|
||||
to prepare a downloaded Armbian image, first extract it and then increase
|
||||
its size to one gigabyte as follows:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ qemu-img resize Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.img 1G
|
||||
|
||||
You can choose to attach the selected image either as an SD card or as USB mass storage.
|
||||
For example, to boot using the Orange Pi PC Debian image on SD card, simply add the -sd
|
||||
argument and provide the proper root= kernel parameter:
|
||||
@@ -213,12 +223,12 @@ Next, unzip the NetBSD image and write the U-Boot binary including SPL using:
|
||||
$ dd if=/path/to/u-boot-sunxi-with-spl.bin of=armv7.img bs=1024 seek=8 conv=notrunc
|
||||
|
||||
Finally, before starting the machine the SD image must be extended such
|
||||
that the NetBSD kernel will not conclude the NetBSD partition is larger than
|
||||
the emulated SD card:
|
||||
that the size of the SD image is a power of two and that the NetBSD kernel
|
||||
will not conclude the NetBSD partition is larger than the emulated SD card:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ dd if=/dev/zero bs=1M count=64 >> armv7.img
|
||||
$ qemu-img resize armv7.img 2G
|
||||
|
||||
Start the machine using the following command:
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ static FsDriverTable FsDrivers[] = {
|
||||
"throttling.iops-read-max-length",
|
||||
"throttling.iops-write-max-length",
|
||||
"throttling.iops-size",
|
||||
NULL
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -85,6 +86,7 @@ static FsDriverTable FsDrivers[] = {
|
||||
.ops = &synth_ops,
|
||||
.opts = (const char * []) {
|
||||
COMMON_FS_DRIVER_OPTIONS,
|
||||
NULL
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -95,6 +97,7 @@ static FsDriverTable FsDrivers[] = {
|
||||
"socket",
|
||||
"sock_fd",
|
||||
"writeout",
|
||||
NULL
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -37,9 +37,22 @@ static inline int openat_file(int dirfd, const char *name, int flags,
|
||||
{
|
||||
int fd, serrno, ret;
|
||||
|
||||
again:
|
||||
fd = openat(dirfd, name, flags | O_NOFOLLOW | O_NOCTTY | O_NONBLOCK,
|
||||
mode);
|
||||
if (fd == -1) {
|
||||
if (errno == EPERM && (flags & O_NOATIME)) {
|
||||
/*
|
||||
* The client passed O_NOATIME but we lack permissions to honor it.
|
||||
* Rather than failing the open, fall back without O_NOATIME. This
|
||||
* doesn't break the semantics on the client side, as the Linux
|
||||
* open(2) man page notes that O_NOATIME "may not be effective on
|
||||
* all filesystems". In particular, NFS and other network
|
||||
* filesystems ignore it entirely.
|
||||
*/
|
||||
flags &= ~O_NOATIME;
|
||||
goto again;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
+12
-22
@@ -28,6 +28,7 @@
|
||||
#include "sysemu/qtest.h"
|
||||
#include "qemu/xxhash.h"
|
||||
#include <math.h>
|
||||
#include <linux/limits.h>
|
||||
|
||||
int open_fd_hw;
|
||||
int total_open_fd;
|
||||
@@ -2102,29 +2103,22 @@ out_nofid:
|
||||
* with qemu_iovec_destroy().
|
||||
*/
|
||||
static void v9fs_init_qiov_from_pdu(QEMUIOVector *qiov, V9fsPDU *pdu,
|
||||
size_t skip, size_t *size,
|
||||
size_t skip, size_t size,
|
||||
bool is_write)
|
||||
{
|
||||
QEMUIOVector elem;
|
||||
struct iovec *iov;
|
||||
unsigned int niov;
|
||||
size_t alloc_size = *size + skip;
|
||||
|
||||
if (is_write) {
|
||||
pdu->s->transport->init_out_iov_from_pdu(pdu, &iov, &niov, alloc_size);
|
||||
pdu->s->transport->init_out_iov_from_pdu(pdu, &iov, &niov, size + skip);
|
||||
} else {
|
||||
pdu->s->transport->init_in_iov_from_pdu(pdu, &iov, &niov, &alloc_size);
|
||||
}
|
||||
|
||||
if (alloc_size < skip) {
|
||||
*size = 0;
|
||||
} else {
|
||||
*size = alloc_size - skip;
|
||||
pdu->s->transport->init_in_iov_from_pdu(pdu, &iov, &niov, size + skip);
|
||||
}
|
||||
|
||||
qemu_iovec_init_external(&elem, iov, niov);
|
||||
qemu_iovec_init(qiov, niov);
|
||||
qemu_iovec_concat(qiov, &elem, skip, *size);
|
||||
qemu_iovec_concat(qiov, &elem, skip, size);
|
||||
}
|
||||
|
||||
static int v9fs_xattr_read(V9fsState *s, V9fsPDU *pdu, V9fsFidState *fidp,
|
||||
@@ -2132,14 +2126,15 @@ static int v9fs_xattr_read(V9fsState *s, V9fsPDU *pdu, V9fsFidState *fidp,
|
||||
{
|
||||
ssize_t err;
|
||||
size_t offset = 7;
|
||||
size_t read_count;
|
||||
uint64_t read_count;
|
||||
QEMUIOVector qiov_full;
|
||||
|
||||
if (fidp->fs.xattr.len < off) {
|
||||
read_count = 0;
|
||||
} else if (fidp->fs.xattr.len - off < max_count) {
|
||||
read_count = fidp->fs.xattr.len - off;
|
||||
} else {
|
||||
read_count = fidp->fs.xattr.len - off;
|
||||
}
|
||||
if (read_count > max_count) {
|
||||
read_count = max_count;
|
||||
}
|
||||
err = pdu_marshal(pdu, offset, "d", read_count);
|
||||
@@ -2148,7 +2143,7 @@ static int v9fs_xattr_read(V9fsState *s, V9fsPDU *pdu, V9fsFidState *fidp,
|
||||
}
|
||||
offset += err;
|
||||
|
||||
v9fs_init_qiov_from_pdu(&qiov_full, pdu, offset, &read_count, false);
|
||||
v9fs_init_qiov_from_pdu(&qiov_full, pdu, offset, read_count, false);
|
||||
err = v9fs_pack(qiov_full.iov, qiov_full.niov, 0,
|
||||
((char *)fidp->fs.xattr.value) + off,
|
||||
read_count);
|
||||
@@ -2277,11 +2272,9 @@ static void coroutine_fn v9fs_read(void *opaque)
|
||||
QEMUIOVector qiov_full;
|
||||
QEMUIOVector qiov;
|
||||
int32_t len;
|
||||
size_t size = max_count;
|
||||
|
||||
v9fs_init_qiov_from_pdu(&qiov_full, pdu, offset + 4, &size, false);
|
||||
v9fs_init_qiov_from_pdu(&qiov_full, pdu, offset + 4, max_count, false);
|
||||
qemu_iovec_init(&qiov, qiov_full.niov);
|
||||
max_count = size;
|
||||
do {
|
||||
qemu_iovec_reset(&qiov);
|
||||
qemu_iovec_concat(&qiov, &qiov_full, count, qiov_full.size - count);
|
||||
@@ -2532,7 +2525,6 @@ static void coroutine_fn v9fs_write(void *opaque)
|
||||
int32_t len = 0;
|
||||
int32_t total = 0;
|
||||
size_t offset = 7;
|
||||
size_t size;
|
||||
V9fsFidState *fidp;
|
||||
V9fsPDU *pdu = opaque;
|
||||
V9fsState *s = pdu->s;
|
||||
@@ -2545,9 +2537,7 @@ static void coroutine_fn v9fs_write(void *opaque)
|
||||
return;
|
||||
}
|
||||
offset += err;
|
||||
size = count;
|
||||
v9fs_init_qiov_from_pdu(&qiov_full, pdu, offset, &size, true);
|
||||
count = size;
|
||||
v9fs_init_qiov_from_pdu(&qiov_full, pdu, offset, count, true);
|
||||
trace_v9fs_write(pdu->tag, pdu->id, fid, off, count, qiov_full.niov);
|
||||
|
||||
fidp = get_fid(pdu, fid);
|
||||
|
||||
+5
-5
@@ -197,22 +197,22 @@ typedef struct V9fsXattr
|
||||
|
||||
typedef struct V9fsDir {
|
||||
DIR *stream;
|
||||
QemuMutex readdir_mutex;
|
||||
CoMutex readdir_mutex;
|
||||
} V9fsDir;
|
||||
|
||||
static inline void v9fs_readdir_lock(V9fsDir *dir)
|
||||
{
|
||||
qemu_mutex_lock(&dir->readdir_mutex);
|
||||
qemu_co_mutex_lock(&dir->readdir_mutex);
|
||||
}
|
||||
|
||||
static inline void v9fs_readdir_unlock(V9fsDir *dir)
|
||||
{
|
||||
qemu_mutex_unlock(&dir->readdir_mutex);
|
||||
qemu_co_mutex_unlock(&dir->readdir_mutex);
|
||||
}
|
||||
|
||||
static inline void v9fs_readdir_init(V9fsDir *dir)
|
||||
{
|
||||
qemu_mutex_init(&dir->readdir_mutex);
|
||||
qemu_co_mutex_init(&dir->readdir_mutex);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -436,7 +436,7 @@ struct V9fsTransport {
|
||||
ssize_t (*pdu_vunmarshal)(V9fsPDU *pdu, size_t offset, const char *fmt,
|
||||
va_list ap);
|
||||
void (*init_in_iov_from_pdu)(V9fsPDU *pdu, struct iovec **piov,
|
||||
unsigned int *pniov, size_t *size);
|
||||
unsigned int *pniov, size_t size);
|
||||
void (*init_out_iov_from_pdu)(V9fsPDU *pdu, struct iovec **piov,
|
||||
unsigned int *pniov, size_t size);
|
||||
void (*push_and_notify)(V9fsPDU *pdu);
|
||||
|
||||
@@ -147,22 +147,19 @@ static ssize_t virtio_pdu_vunmarshal(V9fsPDU *pdu, size_t offset,
|
||||
}
|
||||
|
||||
static void virtio_init_in_iov_from_pdu(V9fsPDU *pdu, struct iovec **piov,
|
||||
unsigned int *pniov, size_t *size)
|
||||
unsigned int *pniov, size_t size)
|
||||
{
|
||||
V9fsState *s = pdu->s;
|
||||
V9fsVirtioState *v = container_of(s, V9fsVirtioState, state);
|
||||
VirtQueueElement *elem = v->elems[pdu->idx];
|
||||
size_t buf_size = iov_size(elem->in_sg, elem->in_num);
|
||||
|
||||
if (buf_size < P9_IOHDRSZ) {
|
||||
if (buf_size < size) {
|
||||
VirtIODevice *vdev = VIRTIO_DEVICE(v);
|
||||
|
||||
virtio_error(vdev,
|
||||
"VirtFS reply type %d needs %zu bytes, buffer has %zu, less than minimum",
|
||||
pdu->id + 1, *size, buf_size);
|
||||
}
|
||||
if (buf_size < *size) {
|
||||
*size = buf_size;
|
||||
"VirtFS reply type %d needs %zu bytes, buffer has %zu",
|
||||
pdu->id + 1, size, buf_size);
|
||||
}
|
||||
|
||||
*piov = elem->in_sg;
|
||||
|
||||
+29
-12
@@ -37,6 +37,7 @@ typedef struct Xen9pfsRing {
|
||||
|
||||
struct iovec *sg;
|
||||
QEMUBH *bh;
|
||||
Coroutine *co;
|
||||
|
||||
/* local copies, so that we can read/write PDU data directly from
|
||||
* the ring */
|
||||
@@ -137,7 +138,8 @@ static ssize_t xen_9pfs_pdu_vmarshal(V9fsPDU *pdu,
|
||||
ret = v9fs_iov_vmarshal(in_sg, num, offset, 0, fmt, ap);
|
||||
if (ret < 0) {
|
||||
xen_pv_printf(&xen_9pfs->xendev, 0,
|
||||
"Failed to encode VirtFS request type %d\n", pdu->id + 1);
|
||||
"Failed to encode VirtFS reply type %d\n",
|
||||
pdu->id + 1);
|
||||
xen_be_set_state(&xen_9pfs->xendev, XenbusStateClosing);
|
||||
xen_9pfs_disconnect(&xen_9pfs->xendev);
|
||||
}
|
||||
@@ -187,7 +189,7 @@ static void xen_9pfs_init_out_iov_from_pdu(V9fsPDU *pdu,
|
||||
static void xen_9pfs_init_in_iov_from_pdu(V9fsPDU *pdu,
|
||||
struct iovec **piov,
|
||||
unsigned int *pniov,
|
||||
size_t *size)
|
||||
size_t size)
|
||||
{
|
||||
Xen9pfsDev *xen_9pfs = container_of(pdu->s, Xen9pfsDev, state);
|
||||
Xen9pfsRing *ring = &xen_9pfs->rings[pdu->tag % xen_9pfs->num_rings];
|
||||
@@ -197,19 +199,20 @@ static void xen_9pfs_init_in_iov_from_pdu(V9fsPDU *pdu,
|
||||
g_free(ring->sg);
|
||||
|
||||
ring->sg = g_new0(struct iovec, 2);
|
||||
xen_9pfs_in_sg(ring, ring->sg, &num, pdu->idx, *size);
|
||||
ring->co = qemu_coroutine_self();
|
||||
/* make sure other threads see ring->co changes before continuing */
|
||||
smp_wmb();
|
||||
|
||||
again:
|
||||
xen_9pfs_in_sg(ring, ring->sg, &num, pdu->idx, size);
|
||||
buf_size = iov_size(ring->sg, num);
|
||||
if (buf_size < P9_IOHDRSZ) {
|
||||
xen_pv_printf(&xen_9pfs->xendev, 0, "Xen 9pfs request type %d"
|
||||
"needs %zu bytes, buffer has %zu, less than minimum\n",
|
||||
pdu->id, *size, buf_size);
|
||||
xen_be_set_state(&xen_9pfs->xendev, XenbusStateClosing);
|
||||
xen_9pfs_disconnect(&xen_9pfs->xendev);
|
||||
}
|
||||
if (buf_size < *size) {
|
||||
*size = buf_size;
|
||||
if (buf_size < size) {
|
||||
qemu_coroutine_yield();
|
||||
goto again;
|
||||
}
|
||||
ring->co = NULL;
|
||||
/* make sure other threads see ring->co changes before continuing */
|
||||
smp_wmb();
|
||||
|
||||
*piov = ring->sg;
|
||||
*pniov = num;
|
||||
@@ -294,6 +297,20 @@ static int xen_9pfs_receive(Xen9pfsRing *ring)
|
||||
static void xen_9pfs_bh(void *opaque)
|
||||
{
|
||||
Xen9pfsRing *ring = opaque;
|
||||
bool wait;
|
||||
|
||||
again:
|
||||
wait = ring->co != NULL && qemu_coroutine_entered(ring->co);
|
||||
/* paired with the smb_wmb barriers in xen_9pfs_init_in_iov_from_pdu */
|
||||
smp_rmb();
|
||||
if (wait) {
|
||||
cpu_relax();
|
||||
goto again;
|
||||
}
|
||||
|
||||
if (ring->co != NULL) {
|
||||
qemu_coroutine_enter_if_inactive(ring->co);
|
||||
}
|
||||
xen_9pfs_receive(ring);
|
||||
}
|
||||
|
||||
|
||||
+6
-3
@@ -461,7 +461,8 @@ static void acpi_pm_evt_write(void *opaque, hwaddr addr, uint64_t val,
|
||||
static const MemoryRegionOps acpi_pm_evt_ops = {
|
||||
.read = acpi_pm_evt_read,
|
||||
.write = acpi_pm_evt_write,
|
||||
.valid.min_access_size = 2,
|
||||
.impl.min_access_size = 2,
|
||||
.valid.min_access_size = 1,
|
||||
.valid.max_access_size = 2,
|
||||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
};
|
||||
@@ -530,7 +531,8 @@ static void acpi_pm_tmr_write(void *opaque, hwaddr addr, uint64_t val,
|
||||
static const MemoryRegionOps acpi_pm_tmr_ops = {
|
||||
.read = acpi_pm_tmr_read,
|
||||
.write = acpi_pm_tmr_write,
|
||||
.valid.min_access_size = 4,
|
||||
.impl.min_access_size = 4,
|
||||
.valid.min_access_size = 1,
|
||||
.valid.max_access_size = 4,
|
||||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
};
|
||||
@@ -602,7 +604,8 @@ static void acpi_pm_cnt_write(void *opaque, hwaddr addr, uint64_t val,
|
||||
static const MemoryRegionOps acpi_pm_cnt_ops = {
|
||||
.read = acpi_pm_cnt_read,
|
||||
.write = acpi_pm_cnt_write,
|
||||
.valid.min_access_size = 2,
|
||||
.impl.min_access_size = 2,
|
||||
.valid.min_access_size = 1,
|
||||
.valid.max_access_size = 2,
|
||||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
};
|
||||
|
||||
+1
-1
@@ -555,7 +555,7 @@ static void create_pcie(SBSAMachineState *sms)
|
||||
|
||||
for (i = 0; i < GPEX_NUM_IRQS; i++) {
|
||||
sysbus_connect_irq(SYS_BUS_DEVICE(dev), i,
|
||||
qdev_get_gpio_in(sms->gic, irq + 1));
|
||||
qdev_get_gpio_in(sms->gic, irq + i));
|
||||
gpex_set_irq_num(GPEX_HOST(dev), i, irq + i);
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -643,6 +643,9 @@ static void es1370_transfer_audio (ES1370State *s, struct chan *d, int loop_sel,
|
||||
int csc_bytes = (csc + 1) << d->shift;
|
||||
int cnt = d->frame_cnt >> 16;
|
||||
int size = d->frame_cnt & 0xffff;
|
||||
if (size < cnt) {
|
||||
return;
|
||||
}
|
||||
int left = ((size - cnt + 1) << 2) + d->leftover;
|
||||
int transferred = 0;
|
||||
int temp = MIN (max, MIN (left, csc_bytes));
|
||||
@@ -651,7 +654,7 @@ static void es1370_transfer_audio (ES1370State *s, struct chan *d, int loop_sel,
|
||||
addr += (cnt << 2) + d->leftover;
|
||||
|
||||
if (index == ADC_CHANNEL) {
|
||||
while (temp) {
|
||||
while (temp > 0) {
|
||||
int acquired, to_copy;
|
||||
|
||||
to_copy = MIN ((size_t) temp, sizeof (tmpbuf));
|
||||
@@ -669,7 +672,7 @@ static void es1370_transfer_audio (ES1370State *s, struct chan *d, int loop_sel,
|
||||
else {
|
||||
SWVoiceOut *voice = s->dac_voice[index];
|
||||
|
||||
while (temp) {
|
||||
while (temp > 0) {
|
||||
int copied, to_copy;
|
||||
|
||||
to_copy = MIN ((size_t) temp, sizeof (tmpbuf));
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#define GUSregb(position) (* (gusptr+(position)))
|
||||
#define GUSregw(position) (*(uint16_t *) (gusptr+(position)))
|
||||
#define GUSregd(position) (*(uint16_t *)(gusptr+(position)))
|
||||
#define GUSregd(position) (*(uint32_t *)(gusptr + (position)))
|
||||
|
||||
/* size given in bytes */
|
||||
unsigned int gus_read(GUSEmuState * state, int port, int size)
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#define GUSregb(position) (* (gusptr+(position)))
|
||||
#define GUSregw(position) (*(uint16_t *) (gusptr+(position)))
|
||||
#define GUSregd(position) (*(uint16_t *)(gusptr+(position)))
|
||||
#define GUSregd(position) (*(uint32_t *)(gusptr + (position)))
|
||||
|
||||
#define GUSvoice(position) (*(uint16_t *)(voiceptr+(position)))
|
||||
|
||||
|
||||
+4
-8
@@ -1199,20 +1199,16 @@ static const MemoryRegionOps artist_reg_ops = {
|
||||
.read = artist_reg_read,
|
||||
.write = artist_reg_write,
|
||||
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||
.valid = {
|
||||
.min_access_size = 1,
|
||||
.max_access_size = 4,
|
||||
},
|
||||
.impl.min_access_size = 1,
|
||||
.impl.max_access_size = 4,
|
||||
};
|
||||
|
||||
static const MemoryRegionOps artist_vram_ops = {
|
||||
.read = artist_vram_read,
|
||||
.write = artist_vram_write,
|
||||
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||
.valid = {
|
||||
.min_access_size = 1,
|
||||
.max_access_size = 4,
|
||||
},
|
||||
.impl.min_access_size = 1,
|
||||
.impl.max_access_size = 4,
|
||||
};
|
||||
|
||||
static void artist_draw_cursor(ARTISTState *s)
|
||||
|
||||
+8
-2
@@ -285,8 +285,11 @@ static uint64_t ati_mm_read(void *opaque, hwaddr addr, unsigned int size)
|
||||
if (idx <= s->vga.vram_size - size) {
|
||||
val = ldn_le_p(s->vga.vram_ptr + idx, size);
|
||||
}
|
||||
} else {
|
||||
} else if (s->regs.mm_index > MM_DATA + 3) {
|
||||
val = ati_mm_read(s, s->regs.mm_index + addr - MM_DATA, size);
|
||||
} else {
|
||||
qemu_log_mask(LOG_GUEST_ERROR,
|
||||
"ati_mm_read: mm_index too small: %u\n", s->regs.mm_index);
|
||||
}
|
||||
break;
|
||||
case BIOS_0_SCRATCH ... BUS_CNTL - 1:
|
||||
@@ -520,8 +523,11 @@ static void ati_mm_write(void *opaque, hwaddr addr,
|
||||
if (idx <= s->vga.vram_size - size) {
|
||||
stn_le_p(s->vga.vram_ptr + idx, size, data);
|
||||
}
|
||||
} else {
|
||||
} else if (s->regs.mm_index > MM_DATA + 3) {
|
||||
ati_mm_write(s, s->regs.mm_index + addr - MM_DATA, data, size);
|
||||
} else {
|
||||
qemu_log_mask(LOG_GUEST_ERROR,
|
||||
"ati_mm_write: mm_index too small: %u\n", s->regs.mm_index);
|
||||
}
|
||||
break;
|
||||
case BIOS_0_SCRATCH ... BUS_CNTL - 1:
|
||||
|
||||
@@ -2549,6 +2549,11 @@ static bool vtd_process_inv_desc(IntelIOMMUState *s)
|
||||
/* Try to fetch and process more Invalidation Descriptors */
|
||||
static void vtd_fetch_inv_desc(IntelIOMMUState *s)
|
||||
{
|
||||
int qi_shift;
|
||||
|
||||
/* Refer to 10.4.23 of VT-d spec 3.0 */
|
||||
qi_shift = s->iq_dw ? VTD_IQH_QH_SHIFT_5 : VTD_IQH_QH_SHIFT_4;
|
||||
|
||||
trace_vtd_inv_qi_fetch();
|
||||
|
||||
if (s->iq_tail >= s->iq_size) {
|
||||
@@ -2567,7 +2572,7 @@ static void vtd_fetch_inv_desc(IntelIOMMUState *s)
|
||||
}
|
||||
/* Must update the IQH_REG in time */
|
||||
vtd_set_quad_raw(s, DMAR_IQH_REG,
|
||||
(((uint64_t)(s->iq_head)) << VTD_IQH_QH_SHIFT) &
|
||||
(((uint64_t)(s->iq_head)) << qi_shift) &
|
||||
VTD_IQH_QH_MASK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,7 +230,8 @@
|
||||
#define VTD_IQA_DW_MASK 0x800
|
||||
|
||||
/* IQH_REG */
|
||||
#define VTD_IQH_QH_SHIFT 4
|
||||
#define VTD_IQH_QH_SHIFT_4 4
|
||||
#define VTD_IQH_QH_SHIFT_5 5
|
||||
#define VTD_IQH_QH_MASK 0x7fff0ULL
|
||||
|
||||
/* ICS_REG */
|
||||
|
||||
@@ -34,9 +34,9 @@
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/log.h"
|
||||
#include "net/net.h"
|
||||
#include "net/tap.h"
|
||||
#include "hw/hw.h"
|
||||
#include "hw/pci/msi.h"
|
||||
#include "hw/pci/msix.h"
|
||||
#include "sysemu/runstate.h"
|
||||
@@ -2816,11 +2816,15 @@ e1000e_set_psrctl(E1000ECore *core, int index, uint32_t val)
|
||||
if (core->mac[RCTL] & E1000_RCTL_DTYP_MASK) {
|
||||
|
||||
if ((val & E1000_PSRCTL_BSIZE0_MASK) == 0) {
|
||||
hw_error("e1000e: PSRCTL.BSIZE0 cannot be zero");
|
||||
qemu_log_mask(LOG_GUEST_ERROR,
|
||||
"e1000e: PSRCTL.BSIZE0 cannot be zero");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((val & E1000_PSRCTL_BSIZE1_MASK) == 0) {
|
||||
hw_error("e1000e: PSRCTL.BSIZE1 cannot be zero");
|
||||
qemu_log_mask(LOG_GUEST_ERROR,
|
||||
"e1000e: PSRCTL.BSIZE1 cannot be zero");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -171,9 +171,6 @@ static void tulip_copy_rx_bytes(TULIPState *s, struct tulip_descriptor *desc)
|
||||
len = s->rx_frame_len;
|
||||
}
|
||||
|
||||
if (s->rx_frame_len + len > sizeof(s->rx_frame)) {
|
||||
return;
|
||||
}
|
||||
pci_dma_write(&s->dev, desc->buf_addr1, s->rx_frame +
|
||||
(s->rx_frame_size - s->rx_frame_len), len);
|
||||
s->rx_frame_len -= len;
|
||||
@@ -186,9 +183,6 @@ static void tulip_copy_rx_bytes(TULIPState *s, struct tulip_descriptor *desc)
|
||||
len = s->rx_frame_len;
|
||||
}
|
||||
|
||||
if (s->rx_frame_len + len > sizeof(s->rx_frame)) {
|
||||
return;
|
||||
}
|
||||
pci_dma_write(&s->dev, desc->buf_addr2, s->rx_frame +
|
||||
(s->rx_frame_size - s->rx_frame_len), len);
|
||||
s->rx_frame_len -= len;
|
||||
|
||||
+5
-24
@@ -77,25 +77,6 @@
|
||||
tso/gso/gro 'off'. */
|
||||
#define VIRTIO_NET_RSC_DEFAULT_INTERVAL 300000
|
||||
|
||||
/* temporary until standard header include it */
|
||||
#if !defined(VIRTIO_NET_HDR_F_RSC_INFO)
|
||||
|
||||
#define VIRTIO_NET_HDR_F_RSC_INFO 4 /* rsc_ext data in csum_ fields */
|
||||
#define VIRTIO_NET_F_RSC_EXT 61
|
||||
|
||||
static inline __virtio16 *virtio_net_rsc_ext_num_packets(
|
||||
struct virtio_net_hdr *hdr)
|
||||
{
|
||||
return &hdr->csum_start;
|
||||
}
|
||||
|
||||
static inline __virtio16 *virtio_net_rsc_ext_num_dupacks(
|
||||
struct virtio_net_hdr *hdr)
|
||||
{
|
||||
return &hdr->csum_offset;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static VirtIOFeature feature_sizes[] = {
|
||||
{.flags = 1ULL << VIRTIO_NET_F_MAC,
|
||||
@@ -1539,15 +1520,15 @@ static size_t virtio_net_rsc_drain_seg(VirtioNetRscChain *chain,
|
||||
VirtioNetRscSeg *seg)
|
||||
{
|
||||
int ret;
|
||||
struct virtio_net_hdr *h;
|
||||
struct virtio_net_hdr_v1 *h;
|
||||
|
||||
h = (struct virtio_net_hdr *)seg->buf;
|
||||
h = (struct virtio_net_hdr_v1 *)seg->buf;
|
||||
h->flags = 0;
|
||||
h->gso_type = VIRTIO_NET_HDR_GSO_NONE;
|
||||
|
||||
if (seg->is_coalesced) {
|
||||
*virtio_net_rsc_ext_num_packets(h) = seg->packets;
|
||||
*virtio_net_rsc_ext_num_dupacks(h) = seg->dup_ack;
|
||||
h->rsc.segments = seg->packets;
|
||||
h->rsc.dup_acks = seg->dup_ack;
|
||||
h->flags = VIRTIO_NET_HDR_F_RSC_INFO;
|
||||
if (chain->proto == ETH_P_IP) {
|
||||
h->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
|
||||
@@ -2828,7 +2809,7 @@ static bool failover_replug_primary(VirtIONet *n, Error **errp)
|
||||
if (err) {
|
||||
goto out;
|
||||
}
|
||||
hotplug_handler_plug(hotplug_ctrl, n->primary_dev, errp);
|
||||
hotplug_handler_plug(hotplug_ctrl, n->primary_dev, &err);
|
||||
}
|
||||
|
||||
out:
|
||||
|
||||
+21
-3
@@ -21,14 +21,21 @@
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/cutils.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "hw/nvram/chrp_nvram.h"
|
||||
#include "sysemu/sysemu.h"
|
||||
|
||||
static int chrp_nvram_set_var(uint8_t *nvram, int addr, const char *str)
|
||||
static int chrp_nvram_set_var(uint8_t *nvram, int addr, const char *str,
|
||||
int max_len)
|
||||
{
|
||||
int len;
|
||||
|
||||
len = strlen(str) + 1;
|
||||
|
||||
if (max_len < len) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(&nvram[addr], str, len);
|
||||
|
||||
return addr + len;
|
||||
@@ -38,19 +45,26 @@ static int chrp_nvram_set_var(uint8_t *nvram, int addr, const char *str)
|
||||
* Create a "system partition", used for the Open Firmware
|
||||
* environment variables.
|
||||
*/
|
||||
int chrp_nvram_create_system_partition(uint8_t *data, int min_len)
|
||||
int chrp_nvram_create_system_partition(uint8_t *data, int min_len, int max_len)
|
||||
{
|
||||
ChrpNvramPartHdr *part_header;
|
||||
unsigned int i;
|
||||
int end;
|
||||
|
||||
if (max_len < sizeof(*part_header)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
part_header = (ChrpNvramPartHdr *)data;
|
||||
part_header->signature = CHRP_NVPART_SYSTEM;
|
||||
pstrcpy(part_header->name, sizeof(part_header->name), "system");
|
||||
|
||||
end = sizeof(ChrpNvramPartHdr);
|
||||
for (i = 0; i < nb_prom_envs; i++) {
|
||||
end = chrp_nvram_set_var(data, end, prom_envs[i]);
|
||||
end = chrp_nvram_set_var(data, end, prom_envs[i], max_len - end);
|
||||
if (end == -1) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
/* End marker */
|
||||
@@ -65,6 +79,10 @@ int chrp_nvram_create_system_partition(uint8_t *data, int min_len)
|
||||
chrp_nvram_finish_partition(part_header, end);
|
||||
|
||||
return end;
|
||||
|
||||
fail:
|
||||
error_report("NVRAM is too small. Try to pass less data to -prom-env");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -152,7 +152,7 @@ static void pmac_format_nvram_partition_of(MacIONVRAMState *nvr, int off,
|
||||
|
||||
/* OpenBIOS nvram variables partition */
|
||||
sysp_end = chrp_nvram_create_system_partition(&nvr->data[off],
|
||||
DEF_SYSTEM_SIZE) + off;
|
||||
DEF_SYSTEM_SIZE, len) + off;
|
||||
|
||||
/* Free space partition */
|
||||
chrp_nvram_create_free_partition(&nvr->data[sysp_end], len - sysp_end);
|
||||
|
||||
@@ -188,7 +188,8 @@ static void spapr_nvram_realize(SpaprVioDevice *dev, Error **errp)
|
||||
}
|
||||
} else if (nb_prom_envs > 0) {
|
||||
/* Create a system partition to pass the -prom-env variables */
|
||||
chrp_nvram_create_system_partition(nvram->buf, MIN_NVRAM_SIZE / 4);
|
||||
chrp_nvram_create_system_partition(nvram->buf, MIN_NVRAM_SIZE / 4,
|
||||
nvram->size);
|
||||
chrp_nvram_create_free_partition(&nvram->buf[MIN_NVRAM_SIZE / 4],
|
||||
nvram->size - MIN_NVRAM_SIZE / 4);
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ static const MemoryRegionOps sifive_clint_ops = {
|
||||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
.valid = {
|
||||
.min_access_size = 4,
|
||||
.max_access_size = 4
|
||||
.max_access_size = 8
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ static const MemoryRegionOps sifive_test_ops = {
|
||||
.write = sifive_test_write,
|
||||
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||
.valid = {
|
||||
.min_access_size = 4,
|
||||
.min_access_size = 2,
|
||||
.max_access_size = 4
|
||||
}
|
||||
};
|
||||
|
||||
+10
-8
@@ -786,9 +786,10 @@ static inline VirtioCcwDevice *to_virtio_ccw_dev_fast(DeviceState *d)
|
||||
static uint8_t virtio_set_ind_atomic(SubchDev *sch, uint64_t ind_loc,
|
||||
uint8_t to_be_set)
|
||||
{
|
||||
uint8_t ind_old, ind_new;
|
||||
uint8_t expected, actual;
|
||||
hwaddr len = 1;
|
||||
uint8_t *ind_addr;
|
||||
/* avoid multiple fetches */
|
||||
uint8_t volatile *ind_addr;
|
||||
|
||||
ind_addr = cpu_physical_memory_map(ind_loc, &len, true);
|
||||
if (!ind_addr) {
|
||||
@@ -796,14 +797,15 @@ static uint8_t virtio_set_ind_atomic(SubchDev *sch, uint64_t ind_loc,
|
||||
__func__, sch->cssid, sch->ssid, sch->schid);
|
||||
return -1;
|
||||
}
|
||||
actual = *ind_addr;
|
||||
do {
|
||||
ind_old = *ind_addr;
|
||||
ind_new = ind_old | to_be_set;
|
||||
} while (atomic_cmpxchg(ind_addr, ind_old, ind_new) != ind_old);
|
||||
trace_virtio_ccw_set_ind(ind_loc, ind_old, ind_new);
|
||||
cpu_physical_memory_unmap(ind_addr, len, 1, len);
|
||||
expected = actual;
|
||||
actual = atomic_cmpxchg(ind_addr, expected, expected | to_be_set);
|
||||
} while (actual != expected);
|
||||
trace_virtio_ccw_set_ind(ind_loc, actual, actual | to_be_set);
|
||||
cpu_physical_memory_unmap((void *)ind_addr, len, 1, len);
|
||||
|
||||
return ind_old;
|
||||
return actual;
|
||||
}
|
||||
|
||||
static void virtio_ccw_notify(DeviceState *d, uint16_t vector)
|
||||
|
||||
+2
-2
@@ -497,12 +497,12 @@ PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem,
|
||||
carddev = qdev_create(qdev_get_child_bus(dev, "sd-bus"), TYPE_SD_CARD);
|
||||
qdev_prop_set_drive(carddev, "drive", blk, &err);
|
||||
if (err) {
|
||||
error_report("failed to init SD card: %s", error_get_pretty(err));
|
||||
error_reportf_err(err, "failed to init SD card: ");
|
||||
return NULL;
|
||||
}
|
||||
object_property_set_bool(OBJECT(carddev), true, "realized", &err);
|
||||
if (err) {
|
||||
error_report("failed to init SD card: %s", error_get_pretty(err));
|
||||
error_reportf_err(err, "failed to init SD card: ");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
+69
-21
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/units.h"
|
||||
#include "qemu/cutils.h"
|
||||
#include "hw/irq.h"
|
||||
#include "hw/registerfields.h"
|
||||
#include "sysemu/block-backend.h"
|
||||
@@ -703,13 +704,13 @@ SDState *sd_init(BlockBackend *blk, bool is_spi)
|
||||
dev = DEVICE(obj);
|
||||
qdev_prop_set_drive(dev, "drive", blk, &err);
|
||||
if (err) {
|
||||
error_report("sd_init failed: %s", error_get_pretty(err));
|
||||
error_reportf_err(err, "sd_init failed: ");
|
||||
return NULL;
|
||||
}
|
||||
qdev_prop_set_bit(dev, "spi", is_spi);
|
||||
object_property_set_bool(obj, true, "realized", &err);
|
||||
if (err) {
|
||||
error_report("sd_init failed: %s", error_get_pretty(err));
|
||||
error_reportf_err(err, "sd_init failed: ");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -905,6 +906,11 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
|
||||
sd->multi_blk_cnt = 0;
|
||||
}
|
||||
|
||||
if (sd_cmd_class[req.cmd] == 6 && FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) {
|
||||
/* Only Standard Capacity cards support class 6 commands */
|
||||
return sd_illegal;
|
||||
}
|
||||
|
||||
switch (req.cmd) {
|
||||
/* Basic commands (Class 0 and Class 1) */
|
||||
case 0: /* CMD0: GO_IDLE_STATE */
|
||||
@@ -1150,12 +1156,15 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
|
||||
case 17: /* CMD17: READ_SINGLE_BLOCK */
|
||||
switch (sd->state) {
|
||||
case sd_transfer_state:
|
||||
|
||||
if (addr + sd->blk_len > sd->size) {
|
||||
sd->card_status |= ADDRESS_ERROR;
|
||||
return sd_r1;
|
||||
}
|
||||
|
||||
sd->state = sd_sendingdata_state;
|
||||
sd->data_start = addr;
|
||||
sd->data_offset = 0;
|
||||
|
||||
if (sd->data_start + sd->blk_len > sd->size)
|
||||
sd->card_status |= ADDRESS_ERROR;
|
||||
return sd_r1;
|
||||
|
||||
default:
|
||||
@@ -1166,12 +1175,15 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
|
||||
case 18: /* CMD18: READ_MULTIPLE_BLOCK */
|
||||
switch (sd->state) {
|
||||
case sd_transfer_state:
|
||||
|
||||
if (addr + sd->blk_len > sd->size) {
|
||||
sd->card_status |= ADDRESS_ERROR;
|
||||
return sd_r1;
|
||||
}
|
||||
|
||||
sd->state = sd_sendingdata_state;
|
||||
sd->data_start = addr;
|
||||
sd->data_offset = 0;
|
||||
|
||||
if (sd->data_start + sd->blk_len > sd->size)
|
||||
sd->card_status |= ADDRESS_ERROR;
|
||||
return sd_r1;
|
||||
|
||||
default:
|
||||
@@ -1211,17 +1223,23 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
|
||||
/* Writing in SPI mode not implemented. */
|
||||
if (sd->spi)
|
||||
break;
|
||||
|
||||
if (addr + sd->blk_len > sd->size) {
|
||||
sd->card_status |= ADDRESS_ERROR;
|
||||
return sd_r1;
|
||||
}
|
||||
|
||||
sd->state = sd_receivingdata_state;
|
||||
sd->data_start = addr;
|
||||
sd->data_offset = 0;
|
||||
sd->blk_written = 0;
|
||||
|
||||
if (sd->data_start + sd->blk_len > sd->size)
|
||||
sd->card_status |= ADDRESS_ERROR;
|
||||
if (sd_wp_addr(sd, sd->data_start))
|
||||
if (sd_wp_addr(sd, sd->data_start)) {
|
||||
sd->card_status |= WP_VIOLATION;
|
||||
if (sd->csd[14] & 0x30)
|
||||
}
|
||||
if (sd->csd[14] & 0x30) {
|
||||
sd->card_status |= WP_VIOLATION;
|
||||
}
|
||||
return sd_r1;
|
||||
|
||||
default:
|
||||
@@ -1235,17 +1253,23 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
|
||||
/* Writing in SPI mode not implemented. */
|
||||
if (sd->spi)
|
||||
break;
|
||||
|
||||
if (addr + sd->blk_len > sd->size) {
|
||||
sd->card_status |= ADDRESS_ERROR;
|
||||
return sd_r1;
|
||||
}
|
||||
|
||||
sd->state = sd_receivingdata_state;
|
||||
sd->data_start = addr;
|
||||
sd->data_offset = 0;
|
||||
sd->blk_written = 0;
|
||||
|
||||
if (sd->data_start + sd->blk_len > sd->size)
|
||||
sd->card_status |= ADDRESS_ERROR;
|
||||
if (sd_wp_addr(sd, sd->data_start))
|
||||
if (sd_wp_addr(sd, sd->data_start)) {
|
||||
sd->card_status |= WP_VIOLATION;
|
||||
if (sd->csd[14] & 0x30)
|
||||
}
|
||||
if (sd->csd[14] & 0x30) {
|
||||
sd->card_status |= WP_VIOLATION;
|
||||
}
|
||||
return sd_r1;
|
||||
|
||||
default:
|
||||
@@ -2085,12 +2109,36 @@ static void sd_realize(DeviceState *dev, Error **errp)
|
||||
return;
|
||||
}
|
||||
|
||||
if (sd->blk && blk_is_read_only(sd->blk)) {
|
||||
error_setg(errp, "Cannot use read-only drive as SD card");
|
||||
return;
|
||||
}
|
||||
|
||||
if (sd->blk) {
|
||||
int64_t blk_size;
|
||||
|
||||
if (blk_is_read_only(sd->blk)) {
|
||||
error_setg(errp, "Cannot use read-only drive as SD card");
|
||||
return;
|
||||
}
|
||||
|
||||
blk_size = blk_getlength(sd->blk);
|
||||
if (blk_size > 0 && !is_power_of_2(blk_size)) {
|
||||
int64_t blk_size_aligned = pow2ceil(blk_size);
|
||||
char *blk_size_str;
|
||||
|
||||
blk_size_str = size_to_str(blk_size);
|
||||
error_setg(errp, "Invalid SD card size: %s", blk_size_str);
|
||||
g_free(blk_size_str);
|
||||
|
||||
blk_size_str = size_to_str(blk_size_aligned);
|
||||
error_append_hint(errp,
|
||||
"SD card size has to be a power of 2, e.g. %s.\n"
|
||||
"You can resize disk images with"
|
||||
" 'qemu-img resize <imagefile> <new-size>'\n"
|
||||
"(note that this will lose data if you make the"
|
||||
" image smaller than it currently is).\n",
|
||||
blk_size_str);
|
||||
g_free(blk_size_str);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ret = blk_set_perm(sd->blk, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE,
|
||||
BLK_PERM_ALL, errp);
|
||||
if (ret < 0) {
|
||||
|
||||
+1
-1
@@ -142,7 +142,7 @@ static void nvram_init(Nvram *nvram, uint8_t *macaddr,
|
||||
memset(image, '\0', sizeof(image));
|
||||
|
||||
/* OpenBIOS nvram variables partition */
|
||||
sysp_end = chrp_nvram_create_system_partition(image, 0);
|
||||
sysp_end = chrp_nvram_create_system_partition(image, 0, 0x1fd0);
|
||||
|
||||
/* Free space partition */
|
||||
chrp_nvram_create_free_partition(&image[sysp_end], 0x1fd0 - sysp_end);
|
||||
|
||||
+1
-1
@@ -136,7 +136,7 @@ static int sun4u_NVRAM_set_params(Nvram *nvram, uint16_t NVRAM_size,
|
||||
memset(image, '\0', sizeof(image));
|
||||
|
||||
/* OpenBIOS nvram variables partition */
|
||||
sysp_end = chrp_nvram_create_system_partition(image, 0);
|
||||
sysp_end = chrp_nvram_create_system_partition(image, 0, 0x1fd0);
|
||||
|
||||
/* Free space partition */
|
||||
chrp_nvram_create_free_partition(&image[sysp_end], 0x1fd0 - sysp_end);
|
||||
|
||||
+4
-1
@@ -306,7 +306,10 @@ static void tpm_spapr_reset(SpaprVioDevice *dev)
|
||||
TPM_SPAPR_BUFFER_MAX);
|
||||
|
||||
tpm_backend_reset(s->be_driver);
|
||||
tpm_spapr_do_startup_tpm(s, s->be_buffer_size);
|
||||
|
||||
if (tpm_spapr_do_startup_tpm(s, s->be_buffer_size) < 0) {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
static enum TPMVersion tpm_spapr_get_version(TPMIf *ti)
|
||||
|
||||
+10
-6
@@ -129,6 +129,7 @@ void usb_wakeup(USBEndpoint *ep, unsigned int stream)
|
||||
static void do_token_setup(USBDevice *s, USBPacket *p)
|
||||
{
|
||||
int request, value, index;
|
||||
unsigned int setup_len;
|
||||
|
||||
if (p->iov.size != 8) {
|
||||
p->status = USB_RET_STALL;
|
||||
@@ -138,14 +139,15 @@ static void do_token_setup(USBDevice *s, USBPacket *p)
|
||||
usb_packet_copy(p, s->setup_buf, p->iov.size);
|
||||
s->setup_index = 0;
|
||||
p->actual_length = 0;
|
||||
s->setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6];
|
||||
if (s->setup_len > sizeof(s->data_buf)) {
|
||||
setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6];
|
||||
if (setup_len > sizeof(s->data_buf)) {
|
||||
fprintf(stderr,
|
||||
"usb_generic_handle_packet: ctrl buffer too small (%d > %zu)\n",
|
||||
s->setup_len, sizeof(s->data_buf));
|
||||
setup_len, sizeof(s->data_buf));
|
||||
p->status = USB_RET_STALL;
|
||||
return;
|
||||
}
|
||||
s->setup_len = setup_len;
|
||||
|
||||
request = (s->setup_buf[0] << 8) | s->setup_buf[1];
|
||||
value = (s->setup_buf[3] << 8) | s->setup_buf[2];
|
||||
@@ -259,26 +261,28 @@ static void do_token_out(USBDevice *s, USBPacket *p)
|
||||
static void do_parameter(USBDevice *s, USBPacket *p)
|
||||
{
|
||||
int i, request, value, index;
|
||||
unsigned int setup_len;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
s->setup_buf[i] = p->parameter >> (i*8);
|
||||
}
|
||||
|
||||
s->setup_state = SETUP_STATE_PARAM;
|
||||
s->setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6];
|
||||
s->setup_index = 0;
|
||||
|
||||
request = (s->setup_buf[0] << 8) | s->setup_buf[1];
|
||||
value = (s->setup_buf[3] << 8) | s->setup_buf[2];
|
||||
index = (s->setup_buf[5] << 8) | s->setup_buf[4];
|
||||
|
||||
if (s->setup_len > sizeof(s->data_buf)) {
|
||||
setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6];
|
||||
if (setup_len > sizeof(s->data_buf)) {
|
||||
fprintf(stderr,
|
||||
"usb_generic_handle_packet: ctrl buffer too small (%d > %zu)\n",
|
||||
s->setup_len, sizeof(s->data_buf));
|
||||
setup_len, sizeof(s->data_buf));
|
||||
p->status = USB_RET_STALL;
|
||||
return;
|
||||
}
|
||||
s->setup_len = setup_len;
|
||||
|
||||
if (p->pid == USB_TOKEN_OUT) {
|
||||
usb_packet_copy(p, s->data_buf, s->setup_len);
|
||||
|
||||
+5
-6
@@ -631,9 +631,9 @@ static void usb_mtp_object_readdir(MTPState *s, MTPObject *o)
|
||||
int64_t id = qemu_file_monitor_add_watch(s->file_monitor, o->path, NULL,
|
||||
file_monitor_event, s, &err);
|
||||
if (id == -1) {
|
||||
error_report("usb-mtp: failed to add watch for %s: %s", o->path,
|
||||
error_get_pretty(err));
|
||||
error_free(err);
|
||||
error_reportf_err(err,
|
||||
"usb-mtp: failed to add watch for %s: ",
|
||||
o->path);
|
||||
} else {
|
||||
trace_usb_mtp_file_monitor_event(s->dev.addr, o->path,
|
||||
"Watch Added");
|
||||
@@ -1276,9 +1276,8 @@ static void usb_mtp_command(MTPState *s, MTPControl *c)
|
||||
|
||||
s->file_monitor = qemu_file_monitor_new(&err);
|
||||
if (err) {
|
||||
error_report("usb-mtp: file monitoring init failed: %s",
|
||||
error_get_pretty(err));
|
||||
error_free(err);
|
||||
error_reportf_err(err,
|
||||
"usb-mtp: file monitoring init failed: ");
|
||||
} else {
|
||||
QTAILQ_INIT(&s->events);
|
||||
}
|
||||
|
||||
+2
-2
@@ -3184,7 +3184,7 @@ static const MemoryRegionOps xhci_oper_ops = {
|
||||
.read = xhci_oper_read,
|
||||
.write = xhci_oper_write,
|
||||
.valid.min_access_size = 4,
|
||||
.valid.max_access_size = 4,
|
||||
.valid.max_access_size = sizeof(dma_addr_t),
|
||||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
};
|
||||
|
||||
@@ -3200,7 +3200,7 @@ static const MemoryRegionOps xhci_runtime_ops = {
|
||||
.read = xhci_runtime_read,
|
||||
.write = xhci_runtime_write,
|
||||
.valid.min_access_size = 4,
|
||||
.valid.max_access_size = 4,
|
||||
.valid.max_access_size = sizeof(dma_addr_t),
|
||||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
};
|
||||
|
||||
|
||||
+76
-57
@@ -466,21 +466,22 @@ static bool get_free_page_hints(VirtIOBalloon *dev)
|
||||
ret = false;
|
||||
goto out;
|
||||
}
|
||||
if (id == dev->free_page_report_cmd_id) {
|
||||
dev->free_page_report_status = FREE_PAGE_REPORT_S_START;
|
||||
if (dev->free_page_hint_status == FREE_PAGE_HINT_S_REQUESTED &&
|
||||
id == dev->free_page_hint_cmd_id) {
|
||||
dev->free_page_hint_status = FREE_PAGE_HINT_S_START;
|
||||
} else {
|
||||
/*
|
||||
* Stop the optimization only when it has started. This
|
||||
* avoids a stale stop sign for the previous command.
|
||||
*/
|
||||
if (dev->free_page_report_status == FREE_PAGE_REPORT_S_START) {
|
||||
dev->free_page_report_status = FREE_PAGE_REPORT_S_STOP;
|
||||
if (dev->free_page_hint_status == FREE_PAGE_HINT_S_START) {
|
||||
dev->free_page_hint_status = FREE_PAGE_HINT_S_STOP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (elem->in_num) {
|
||||
if (dev->free_page_report_status == FREE_PAGE_REPORT_S_START) {
|
||||
if (dev->free_page_hint_status == FREE_PAGE_HINT_S_START) {
|
||||
qemu_guest_free_page_hint(elem->in_sg[0].iov_base,
|
||||
elem->in_sg[0].iov_len);
|
||||
}
|
||||
@@ -506,11 +507,11 @@ static void virtio_ballloon_get_free_page_hints(void *opaque)
|
||||
qemu_mutex_unlock(&dev->free_page_lock);
|
||||
virtio_notify(vdev, vq);
|
||||
/*
|
||||
* Start to poll the vq once the reporting started. Otherwise, continue
|
||||
* Start to poll the vq once the hinting started. Otherwise, continue
|
||||
* only when there are entries on the vq, which need to be given back.
|
||||
*/
|
||||
} while (continue_to_get_hints ||
|
||||
dev->free_page_report_status == FREE_PAGE_REPORT_S_START);
|
||||
dev->free_page_hint_status == FREE_PAGE_HINT_S_START);
|
||||
virtio_queue_set_notification(vq, 1);
|
||||
}
|
||||
|
||||
@@ -531,14 +532,18 @@ static void virtio_balloon_free_page_start(VirtIOBalloon *s)
|
||||
return;
|
||||
}
|
||||
|
||||
if (s->free_page_report_cmd_id == UINT_MAX) {
|
||||
s->free_page_report_cmd_id =
|
||||
VIRTIO_BALLOON_FREE_PAGE_REPORT_CMD_ID_MIN;
|
||||
qemu_mutex_lock(&s->free_page_lock);
|
||||
|
||||
if (s->free_page_hint_cmd_id == UINT_MAX) {
|
||||
s->free_page_hint_cmd_id =
|
||||
VIRTIO_BALLOON_FREE_PAGE_HINT_CMD_ID_MIN;
|
||||
} else {
|
||||
s->free_page_report_cmd_id++;
|
||||
s->free_page_hint_cmd_id++;
|
||||
}
|
||||
|
||||
s->free_page_report_status = FREE_PAGE_REPORT_S_REQUESTED;
|
||||
s->free_page_hint_status = FREE_PAGE_HINT_S_REQUESTED;
|
||||
qemu_mutex_unlock(&s->free_page_lock);
|
||||
|
||||
virtio_notify_config(vdev);
|
||||
}
|
||||
|
||||
@@ -546,18 +551,18 @@ static void virtio_balloon_free_page_stop(VirtIOBalloon *s)
|
||||
{
|
||||
VirtIODevice *vdev = VIRTIO_DEVICE(s);
|
||||
|
||||
if (s->free_page_report_status != FREE_PAGE_REPORT_S_STOP) {
|
||||
if (s->free_page_hint_status != FREE_PAGE_HINT_S_STOP) {
|
||||
/*
|
||||
* The lock also guarantees us that the
|
||||
* virtio_ballloon_get_free_page_hints exits after the
|
||||
* free_page_report_status is set to S_STOP.
|
||||
* free_page_hint_status is set to S_STOP.
|
||||
*/
|
||||
qemu_mutex_lock(&s->free_page_lock);
|
||||
/*
|
||||
* The guest hasn't done the reporting, so host sends a notification
|
||||
* to the guest to actively stop the reporting.
|
||||
* The guest isn't done hinting, so send a notification
|
||||
* to the guest to actively stop the hinting.
|
||||
*/
|
||||
s->free_page_report_status = FREE_PAGE_REPORT_S_STOP;
|
||||
s->free_page_hint_status = FREE_PAGE_HINT_S_STOP;
|
||||
qemu_mutex_unlock(&s->free_page_lock);
|
||||
virtio_notify_config(vdev);
|
||||
}
|
||||
@@ -567,15 +572,20 @@ static void virtio_balloon_free_page_done(VirtIOBalloon *s)
|
||||
{
|
||||
VirtIODevice *vdev = VIRTIO_DEVICE(s);
|
||||
|
||||
s->free_page_report_status = FREE_PAGE_REPORT_S_DONE;
|
||||
virtio_notify_config(vdev);
|
||||
if (s->free_page_hint_status != FREE_PAGE_HINT_S_DONE) {
|
||||
/* See virtio_balloon_free_page_stop() */
|
||||
qemu_mutex_lock(&s->free_page_lock);
|
||||
s->free_page_hint_status = FREE_PAGE_HINT_S_DONE;
|
||||
qemu_mutex_unlock(&s->free_page_lock);
|
||||
virtio_notify_config(vdev);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
virtio_balloon_free_page_report_notify(NotifierWithReturn *n, void *data)
|
||||
virtio_balloon_free_page_hint_notify(NotifierWithReturn *n, void *data)
|
||||
{
|
||||
VirtIOBalloon *dev = container_of(n, VirtIOBalloon,
|
||||
free_page_report_notify);
|
||||
free_page_hint_notify);
|
||||
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
|
||||
PrecopyNotifyData *pnd = data;
|
||||
|
||||
@@ -592,17 +602,26 @@ virtio_balloon_free_page_report_notify(NotifierWithReturn *n, void *data)
|
||||
case PRECOPY_NOTIFY_SETUP:
|
||||
precopy_enable_free_page_optimization();
|
||||
break;
|
||||
case PRECOPY_NOTIFY_COMPLETE:
|
||||
case PRECOPY_NOTIFY_CLEANUP:
|
||||
case PRECOPY_NOTIFY_BEFORE_BITMAP_SYNC:
|
||||
virtio_balloon_free_page_stop(dev);
|
||||
break;
|
||||
case PRECOPY_NOTIFY_AFTER_BITMAP_SYNC:
|
||||
if (vdev->vm_running) {
|
||||
virtio_balloon_free_page_start(dev);
|
||||
} else {
|
||||
virtio_balloon_free_page_done(dev);
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* Set S_DONE before migrating the vmstate, so the guest will reuse
|
||||
* all hinted pages once running on the destination. Fall through.
|
||||
*/
|
||||
case PRECOPY_NOTIFY_CLEANUP:
|
||||
/*
|
||||
* Especially, if something goes wrong during precopy or if migration
|
||||
* is canceled, we have to properly communicate S_DONE to the VM.
|
||||
*/
|
||||
virtio_balloon_free_page_done(dev);
|
||||
break;
|
||||
case PRECOPY_NOTIFY_COMPLETE:
|
||||
break;
|
||||
default:
|
||||
virtio_error(vdev, "%s: %d reason unknown", __func__, pnd->reason);
|
||||
@@ -624,7 +643,7 @@ static size_t virtio_balloon_config_size(VirtIOBalloon *s)
|
||||
if (virtio_has_feature(features, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) {
|
||||
return offsetof(struct virtio_balloon_config, poison_val);
|
||||
}
|
||||
return offsetof(struct virtio_balloon_config, free_page_report_cmd_id);
|
||||
return offsetof(struct virtio_balloon_config, free_page_hint_cmd_id);
|
||||
}
|
||||
|
||||
static void virtio_balloon_get_config(VirtIODevice *vdev, uint8_t *config_data)
|
||||
@@ -635,14 +654,14 @@ static void virtio_balloon_get_config(VirtIODevice *vdev, uint8_t *config_data)
|
||||
config.num_pages = cpu_to_le32(dev->num_pages);
|
||||
config.actual = cpu_to_le32(dev->actual);
|
||||
|
||||
if (dev->free_page_report_status == FREE_PAGE_REPORT_S_REQUESTED) {
|
||||
config.free_page_report_cmd_id =
|
||||
cpu_to_le32(dev->free_page_report_cmd_id);
|
||||
} else if (dev->free_page_report_status == FREE_PAGE_REPORT_S_STOP) {
|
||||
config.free_page_report_cmd_id =
|
||||
if (dev->free_page_hint_status == FREE_PAGE_HINT_S_REQUESTED) {
|
||||
config.free_page_hint_cmd_id =
|
||||
cpu_to_le32(dev->free_page_hint_cmd_id);
|
||||
} else if (dev->free_page_hint_status == FREE_PAGE_HINT_S_STOP) {
|
||||
config.free_page_hint_cmd_id =
|
||||
cpu_to_le32(VIRTIO_BALLOON_CMD_ID_STOP);
|
||||
} else if (dev->free_page_report_status == FREE_PAGE_REPORT_S_DONE) {
|
||||
config.free_page_report_cmd_id =
|
||||
} else if (dev->free_page_hint_status == FREE_PAGE_HINT_S_DONE) {
|
||||
config.free_page_hint_cmd_id =
|
||||
cpu_to_le32(VIRTIO_BALLOON_CMD_ID_DONE);
|
||||
}
|
||||
|
||||
@@ -743,14 +762,14 @@ static int virtio_balloon_post_load_device(void *opaque, int version_id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const VMStateDescription vmstate_virtio_balloon_free_page_report = {
|
||||
static const VMStateDescription vmstate_virtio_balloon_free_page_hint = {
|
||||
.name = "virtio-balloon-device/free-page-report",
|
||||
.version_id = 1,
|
||||
.minimum_version_id = 1,
|
||||
.needed = virtio_balloon_free_page_support,
|
||||
.fields = (VMStateField[]) {
|
||||
VMSTATE_UINT32(free_page_report_cmd_id, VirtIOBalloon),
|
||||
VMSTATE_UINT32(free_page_report_status, VirtIOBalloon),
|
||||
VMSTATE_UINT32(free_page_hint_cmd_id, VirtIOBalloon),
|
||||
VMSTATE_UINT32(free_page_hint_status, VirtIOBalloon),
|
||||
VMSTATE_END_OF_LIST()
|
||||
}
|
||||
};
|
||||
@@ -766,7 +785,7 @@ static const VMStateDescription vmstate_virtio_balloon_device = {
|
||||
VMSTATE_END_OF_LIST()
|
||||
},
|
||||
.subsections = (const VMStateDescription * []) {
|
||||
&vmstate_virtio_balloon_free_page_report,
|
||||
&vmstate_virtio_balloon_free_page_hint,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
@@ -789,6 +808,13 @@ static void virtio_balloon_device_realize(DeviceState *dev, Error **errp)
|
||||
return;
|
||||
}
|
||||
|
||||
if (virtio_has_feature(s->host_features, VIRTIO_BALLOON_F_FREE_PAGE_HINT) &&
|
||||
!s->iothread) {
|
||||
error_setg(errp, "'free-page-hint' requires 'iothread' to be set");
|
||||
virtio_cleanup(vdev);
|
||||
return;
|
||||
}
|
||||
|
||||
s->ivq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output);
|
||||
s->dvq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output);
|
||||
s->svq = virtio_add_queue(vdev, 128, virtio_balloon_receive_stats);
|
||||
@@ -797,24 +823,11 @@ static void virtio_balloon_device_realize(DeviceState *dev, Error **errp)
|
||||
VIRTIO_BALLOON_F_FREE_PAGE_HINT)) {
|
||||
s->free_page_vq = virtio_add_queue(vdev, VIRTQUEUE_MAX_SIZE,
|
||||
virtio_balloon_handle_free_page_vq);
|
||||
s->free_page_report_status = FREE_PAGE_REPORT_S_STOP;
|
||||
s->free_page_report_cmd_id =
|
||||
VIRTIO_BALLOON_FREE_PAGE_REPORT_CMD_ID_MIN;
|
||||
s->free_page_report_notify.notify =
|
||||
virtio_balloon_free_page_report_notify;
|
||||
precopy_add_notifier(&s->free_page_report_notify);
|
||||
if (s->iothread) {
|
||||
object_ref(OBJECT(s->iothread));
|
||||
s->free_page_bh = aio_bh_new(iothread_get_aio_context(s->iothread),
|
||||
virtio_ballloon_get_free_page_hints, s);
|
||||
qemu_mutex_init(&s->free_page_lock);
|
||||
qemu_cond_init(&s->free_page_cond);
|
||||
s->block_iothread = false;
|
||||
} else {
|
||||
/* Simply disable this feature if the iothread wasn't created. */
|
||||
s->host_features &= ~(1 << VIRTIO_BALLOON_F_FREE_PAGE_HINT);
|
||||
virtio_error(vdev, "iothread is missing");
|
||||
}
|
||||
precopy_add_notifier(&s->free_page_hint_notify);
|
||||
|
||||
object_ref(OBJECT(s->iothread));
|
||||
s->free_page_bh = aio_bh_new(iothread_get_aio_context(s->iothread),
|
||||
virtio_ballloon_get_free_page_hints, s);
|
||||
}
|
||||
reset_stats(s);
|
||||
}
|
||||
@@ -824,10 +837,11 @@ static void virtio_balloon_device_unrealize(DeviceState *dev, Error **errp)
|
||||
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
|
||||
VirtIOBalloon *s = VIRTIO_BALLOON(dev);
|
||||
|
||||
if (virtio_balloon_free_page_support(s)) {
|
||||
if (s->free_page_bh) {
|
||||
qemu_bh_delete(s->free_page_bh);
|
||||
object_unref(OBJECT(s->iothread));
|
||||
virtio_balloon_free_page_stop(s);
|
||||
precopy_remove_notifier(&s->free_page_report_notify);
|
||||
precopy_remove_notifier(&s->free_page_hint_notify);
|
||||
}
|
||||
balloon_stats_destroy_timer(s);
|
||||
qemu_remove_balloon_handler(s);
|
||||
@@ -892,6 +906,11 @@ static void virtio_balloon_instance_init(Object *obj)
|
||||
{
|
||||
VirtIOBalloon *s = VIRTIO_BALLOON(obj);
|
||||
|
||||
qemu_mutex_init(&s->free_page_lock);
|
||||
qemu_cond_init(&s->free_page_cond);
|
||||
s->free_page_hint_cmd_id = VIRTIO_BALLOON_FREE_PAGE_HINT_CMD_ID_MIN;
|
||||
s->free_page_hint_notify.notify = virtio_balloon_free_page_hint_notify;
|
||||
|
||||
object_property_add(obj, "guest-stats", "guest statistics",
|
||||
balloon_stats_get_all, NULL, NULL, s, NULL);
|
||||
|
||||
|
||||
+24
-10
@@ -1317,11 +1317,12 @@ static uint64_t virtio_pci_notify_read(void *opaque, hwaddr addr,
|
||||
static void virtio_pci_notify_write(void *opaque, hwaddr addr,
|
||||
uint64_t val, unsigned size)
|
||||
{
|
||||
VirtIODevice *vdev = opaque;
|
||||
VirtIOPCIProxy *proxy = VIRTIO_PCI(DEVICE(vdev)->parent_bus->parent);
|
||||
VirtIOPCIProxy *proxy = opaque;
|
||||
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
|
||||
|
||||
unsigned queue = addr / virtio_pci_queue_mem_mult(proxy);
|
||||
|
||||
if (queue < VIRTIO_QUEUE_MAX) {
|
||||
if (vdev != NULL && queue < VIRTIO_QUEUE_MAX) {
|
||||
virtio_queue_notify(vdev, queue);
|
||||
}
|
||||
}
|
||||
@@ -1329,10 +1330,12 @@ static void virtio_pci_notify_write(void *opaque, hwaddr addr,
|
||||
static void virtio_pci_notify_write_pio(void *opaque, hwaddr addr,
|
||||
uint64_t val, unsigned size)
|
||||
{
|
||||
VirtIODevice *vdev = opaque;
|
||||
VirtIOPCIProxy *proxy = opaque;
|
||||
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
|
||||
|
||||
unsigned queue = val;
|
||||
|
||||
if (queue < VIRTIO_QUEUE_MAX) {
|
||||
if (vdev != NULL && queue < VIRTIO_QUEUE_MAX) {
|
||||
virtio_queue_notify(vdev, queue);
|
||||
}
|
||||
}
|
||||
@@ -1356,9 +1359,14 @@ static void virtio_pci_isr_write(void *opaque, hwaddr addr,
|
||||
static uint64_t virtio_pci_device_read(void *opaque, hwaddr addr,
|
||||
unsigned size)
|
||||
{
|
||||
VirtIODevice *vdev = opaque;
|
||||
VirtIOPCIProxy *proxy = opaque;
|
||||
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
|
||||
uint64_t val = 0;
|
||||
|
||||
if (vdev == NULL) {
|
||||
return val;
|
||||
}
|
||||
|
||||
switch (size) {
|
||||
case 1:
|
||||
val = virtio_config_modern_readb(vdev, addr);
|
||||
@@ -1376,7 +1384,13 @@ static uint64_t virtio_pci_device_read(void *opaque, hwaddr addr,
|
||||
static void virtio_pci_device_write(void *opaque, hwaddr addr,
|
||||
uint64_t val, unsigned size)
|
||||
{
|
||||
VirtIODevice *vdev = opaque;
|
||||
VirtIOPCIProxy *proxy = opaque;
|
||||
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
|
||||
|
||||
if (vdev == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (size) {
|
||||
case 1:
|
||||
virtio_config_modern_writeb(vdev, addr, val);
|
||||
@@ -1453,19 +1467,19 @@ static void virtio_pci_modern_regions_init(VirtIOPCIProxy *proxy)
|
||||
|
||||
memory_region_init_io(&proxy->device.mr, OBJECT(proxy),
|
||||
&device_ops,
|
||||
virtio_bus_get_device(&proxy->bus),
|
||||
proxy,
|
||||
"virtio-pci-device",
|
||||
proxy->device.size);
|
||||
|
||||
memory_region_init_io(&proxy->notify.mr, OBJECT(proxy),
|
||||
¬ify_ops,
|
||||
virtio_bus_get_device(&proxy->bus),
|
||||
proxy,
|
||||
"virtio-pci-notify",
|
||||
proxy->notify.size);
|
||||
|
||||
memory_region_init_io(&proxy->notify_pio.mr, OBJECT(proxy),
|
||||
¬ify_pio_ops,
|
||||
virtio_bus_get_device(&proxy->bus),
|
||||
proxy,
|
||||
"virtio-pci-notify-pio",
|
||||
proxy->notify_pio.size);
|
||||
}
|
||||
|
||||
@@ -701,6 +701,9 @@ void aio_context_setup(AioContext *ctx);
|
||||
*/
|
||||
void aio_context_destroy(AioContext *ctx);
|
||||
|
||||
/* Used internally, do not call outside AioContext code */
|
||||
void aio_context_use_g_source(AioContext *ctx);
|
||||
|
||||
/**
|
||||
* aio_context_set_poll_params:
|
||||
* @ctx: the aio context
|
||||
|
||||
@@ -50,7 +50,8 @@ chrp_nvram_finish_partition(ChrpNvramPartHdr *header, uint32_t size)
|
||||
header->checksum = sum & 0xff;
|
||||
}
|
||||
|
||||
int chrp_nvram_create_system_partition(uint8_t *data, int min_len);
|
||||
/* chrp_nvram_create_system_partition() failure is fatal */
|
||||
int chrp_nvram_create_system_partition(uint8_t *data, int min_len, int max_len);
|
||||
int chrp_nvram_create_free_partition(uint8_t *data, int len);
|
||||
|
||||
#endif
|
||||
@@ -23,7 +23,7 @@
|
||||
#define VIRTIO_BALLOON(obj) \
|
||||
OBJECT_CHECK(VirtIOBalloon, (obj), TYPE_VIRTIO_BALLOON)
|
||||
|
||||
#define VIRTIO_BALLOON_FREE_PAGE_REPORT_CMD_ID_MIN 0x80000000
|
||||
#define VIRTIO_BALLOON_FREE_PAGE_HINT_CMD_ID_MIN 0x80000000
|
||||
|
||||
typedef struct virtio_balloon_stat VirtIOBalloonStat;
|
||||
|
||||
@@ -33,20 +33,20 @@ typedef struct virtio_balloon_stat_modern {
|
||||
uint64_t val;
|
||||
} VirtIOBalloonStatModern;
|
||||
|
||||
enum virtio_balloon_free_page_report_status {
|
||||
FREE_PAGE_REPORT_S_STOP = 0,
|
||||
FREE_PAGE_REPORT_S_REQUESTED = 1,
|
||||
FREE_PAGE_REPORT_S_START = 2,
|
||||
FREE_PAGE_REPORT_S_DONE = 3,
|
||||
enum virtio_balloon_free_page_hint_status {
|
||||
FREE_PAGE_HINT_S_STOP = 0,
|
||||
FREE_PAGE_HINT_S_REQUESTED = 1,
|
||||
FREE_PAGE_HINT_S_START = 2,
|
||||
FREE_PAGE_HINT_S_DONE = 3,
|
||||
};
|
||||
|
||||
typedef struct VirtIOBalloon {
|
||||
VirtIODevice parent_obj;
|
||||
VirtQueue *ivq, *dvq, *svq, *free_page_vq;
|
||||
uint32_t free_page_report_status;
|
||||
uint32_t free_page_hint_status;
|
||||
uint32_t num_pages;
|
||||
uint32_t actual;
|
||||
uint32_t free_page_report_cmd_id;
|
||||
uint32_t free_page_hint_cmd_id;
|
||||
uint64_t stats[VIRTIO_BALLOON_S_NR];
|
||||
VirtQueueElement *stats_vq_elem;
|
||||
size_t stats_vq_offset;
|
||||
@@ -55,7 +55,7 @@ typedef struct VirtIOBalloon {
|
||||
QEMUBH *free_page_bh;
|
||||
/*
|
||||
* Lock to synchronize threads to access the free page reporting related
|
||||
* fields (e.g. free_page_report_status).
|
||||
* fields (e.g. free_page_hint_status).
|
||||
*/
|
||||
QemuMutex free_page_lock;
|
||||
QemuCond free_page_cond;
|
||||
@@ -64,7 +64,7 @@ typedef struct VirtIOBalloon {
|
||||
* stopped.
|
||||
*/
|
||||
bool block_iothread;
|
||||
NotifierWithReturn free_page_report_notify;
|
||||
NotifierWithReturn free_page_hint_notify;
|
||||
int64_t stats_last_update;
|
||||
int64_t stats_poll_interval;
|
||||
uint32_t host_features;
|
||||
|
||||
@@ -607,4 +607,14 @@ static inline void qemu_reset_optind(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* qemu_get_host_name:
|
||||
* @errp: Error object
|
||||
*
|
||||
* Operating system agnostic way of querying host name.
|
||||
*
|
||||
* Returns allocated hostname (caller should free), NULL on failure.
|
||||
*/
|
||||
char *qemu_get_host_name(Error **errp);
|
||||
|
||||
#endif
|
||||
@@ -596,6 +596,9 @@ struct ethtool_pauseparam {
|
||||
* @ETH_SS_LINK_MODES: link mode names
|
||||
* @ETH_SS_MSG_CLASSES: debug message class names
|
||||
* @ETH_SS_WOL_MODES: wake-on-lan modes
|
||||
* @ETH_SS_SOF_TIMESTAMPING: SOF_TIMESTAMPING_* flags
|
||||
* @ETH_SS_TS_TX_TYPES: timestamping Tx types
|
||||
* @ETH_SS_TS_RX_FILTERS: timestamping Rx filters
|
||||
*/
|
||||
enum ethtool_stringset {
|
||||
ETH_SS_TEST = 0,
|
||||
@@ -610,6 +613,9 @@ enum ethtool_stringset {
|
||||
ETH_SS_LINK_MODES,
|
||||
ETH_SS_MSG_CLASSES,
|
||||
ETH_SS_WOL_MODES,
|
||||
ETH_SS_SOF_TIMESTAMPING,
|
||||
ETH_SS_TS_TX_TYPES,
|
||||
ETH_SS_TS_RX_FILTERS,
|
||||
|
||||
/* add new constants above here */
|
||||
ETH_SS_COUNT
|
||||
@@ -1330,6 +1336,7 @@ enum ethtool_fec_config_bits {
|
||||
ETHTOOL_FEC_OFF_BIT,
|
||||
ETHTOOL_FEC_RS_BIT,
|
||||
ETHTOOL_FEC_BASER_BIT,
|
||||
ETHTOOL_FEC_LLRS_BIT,
|
||||
};
|
||||
|
||||
#define ETHTOOL_FEC_NONE (1 << ETHTOOL_FEC_NONE_BIT)
|
||||
@@ -1337,6 +1344,7 @@ enum ethtool_fec_config_bits {
|
||||
#define ETHTOOL_FEC_OFF (1 << ETHTOOL_FEC_OFF_BIT)
|
||||
#define ETHTOOL_FEC_RS (1 << ETHTOOL_FEC_RS_BIT)
|
||||
#define ETHTOOL_FEC_BASER (1 << ETHTOOL_FEC_BASER_BIT)
|
||||
#define ETHTOOL_FEC_LLRS (1 << ETHTOOL_FEC_LLRS_BIT)
|
||||
|
||||
/* CMDs currently supported */
|
||||
#define ETHTOOL_GSET 0x00000001 /* DEPRECATED, Get settings.
|
||||
@@ -1521,7 +1529,7 @@ enum ethtool_link_mode_bit_indices {
|
||||
ETHTOOL_LINK_MODE_400000baseLR8_ER8_FR8_Full_BIT = 71,
|
||||
ETHTOOL_LINK_MODE_400000baseDR8_Full_BIT = 72,
|
||||
ETHTOOL_LINK_MODE_400000baseCR8_Full_BIT = 73,
|
||||
|
||||
ETHTOOL_LINK_MODE_FEC_LLRS_BIT = 74,
|
||||
/* must be last entry */
|
||||
__ETHTOOL_LINK_MODE_MASK_NBITS
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
||||
/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
|
||||
/*
|
||||
* Input event codes
|
||||
*
|
||||
@@ -652,6 +652,9 @@
|
||||
/* Electronic privacy screen control */
|
||||
#define KEY_PRIVACY_SCREEN_TOGGLE 0x279
|
||||
|
||||
/* Select an area of screen to be copied */
|
||||
#define KEY_SELECTIVE_SCREENSHOT 0x27a
|
||||
|
||||
/*
|
||||
* Some keyboards have keys which do not have a defined meaning, these keys
|
||||
* are intended to be programmed / bound to macros by the user. For most
|
||||
|
||||
@@ -605,6 +605,7 @@
|
||||
#define PCI_EXP_SLTCTL_PWR_OFF 0x0400 /* Power Off */
|
||||
#define PCI_EXP_SLTCTL_EIC 0x0800 /* Electromechanical Interlock Control */
|
||||
#define PCI_EXP_SLTCTL_DLLSCE 0x1000 /* Data Link Layer State Changed Enable */
|
||||
#define PCI_EXP_SLTCTL_IBPD_DISABLE 0x4000 /* In-band PD disable */
|
||||
#define PCI_EXP_SLTSTA 26 /* Slot Status */
|
||||
#define PCI_EXP_SLTSTA_ABP 0x0001 /* Attention Button Pressed */
|
||||
#define PCI_EXP_SLTSTA_PFD 0x0002 /* Power Fault Detected */
|
||||
@@ -680,6 +681,7 @@
|
||||
#define PCI_EXP_LNKSTA2 50 /* Link Status 2 */
|
||||
#define PCI_CAP_EXP_ENDPOINT_SIZEOF_V2 52 /* v2 endpoints with link end here */
|
||||
#define PCI_EXP_SLTCAP2 52 /* Slot Capabilities 2 */
|
||||
#define PCI_EXP_SLTCAP2_IBPD 0x00000001 /* In-band PD Disable Supported */
|
||||
#define PCI_EXP_SLTCTL2 56 /* Slot Control 2 */
|
||||
#define PCI_EXP_SLTSTA2 58 /* Slot Status 2 */
|
||||
|
||||
|
||||
@@ -119,6 +119,14 @@ struct vhost_scsi_target {
|
||||
unsigned short reserved;
|
||||
};
|
||||
|
||||
/* VHOST_VDPA specific definitions */
|
||||
|
||||
struct vhost_vdpa_config {
|
||||
uint32_t off;
|
||||
uint32_t len;
|
||||
uint8_t buf[0];
|
||||
};
|
||||
|
||||
/* Feature bits */
|
||||
/* Log all write descriptors. Can be changed while device is active. */
|
||||
#define VHOST_F_LOG_ALL 26
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#define VIRTIO_BALLOON_F_DEFLATE_ON_OOM 2 /* Deflate balloon on OOM */
|
||||
#define VIRTIO_BALLOON_F_FREE_PAGE_HINT 3 /* VQ to report free pages */
|
||||
#define VIRTIO_BALLOON_F_PAGE_POISON 4 /* Guest is using page poisoning */
|
||||
#define VIRTIO_BALLOON_F_REPORTING 5 /* Page reporting virtqueue */
|
||||
|
||||
/* Size of a PFN in the balloon interface. */
|
||||
#define VIRTIO_BALLOON_PFN_SHIFT 12
|
||||
@@ -47,8 +48,15 @@ struct virtio_balloon_config {
|
||||
uint32_t num_pages;
|
||||
/* Number of pages we've actually got in balloon. */
|
||||
uint32_t actual;
|
||||
/* Free page report command id, readonly by guest */
|
||||
uint32_t free_page_report_cmd_id;
|
||||
/*
|
||||
* Free page hint command id, readonly by guest.
|
||||
* Was previously named free_page_report_cmd_id so we
|
||||
* need to carry that name for legacy support.
|
||||
*/
|
||||
union {
|
||||
uint32_t free_page_hint_cmd_id;
|
||||
uint32_t free_page_report_cmd_id; /* deprecated */
|
||||
};
|
||||
/* Stores PAGE_POISON if page poisoning is in use */
|
||||
uint32_t poison_val;
|
||||
};
|
||||
|
||||
@@ -46,5 +46,6 @@
|
||||
#define VIRTIO_ID_IOMMU 23 /* virtio IOMMU */
|
||||
#define VIRTIO_ID_FS 26 /* virtio filesystem */
|
||||
#define VIRTIO_ID_PMEM 27 /* virtio pmem */
|
||||
#define VIRTIO_ID_MAC80211_HWSIM 29 /* virtio mac80211-hwsim */
|
||||
|
||||
#endif /* _LINUX_VIRTIO_IDS_H */
|
||||
@@ -57,6 +57,9 @@
|
||||
* Steering */
|
||||
#define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */
|
||||
|
||||
#define VIRTIO_NET_F_HASH_REPORT 57 /* Supports hash report */
|
||||
#define VIRTIO_NET_F_RSS 60 /* Supports RSS RX steering */
|
||||
#define VIRTIO_NET_F_RSC_EXT 61 /* extended coalescing info */
|
||||
#define VIRTIO_NET_F_STANDBY 62 /* Act as standby for another device
|
||||
* with the same MAC.
|
||||
*/
|
||||
@@ -69,6 +72,17 @@
|
||||
#define VIRTIO_NET_S_LINK_UP 1 /* Link is up */
|
||||
#define VIRTIO_NET_S_ANNOUNCE 2 /* Announcement is needed */
|
||||
|
||||
/* supported/enabled hash types */
|
||||
#define VIRTIO_NET_RSS_HASH_TYPE_IPv4 (1 << 0)
|
||||
#define VIRTIO_NET_RSS_HASH_TYPE_TCPv4 (1 << 1)
|
||||
#define VIRTIO_NET_RSS_HASH_TYPE_UDPv4 (1 << 2)
|
||||
#define VIRTIO_NET_RSS_HASH_TYPE_IPv6 (1 << 3)
|
||||
#define VIRTIO_NET_RSS_HASH_TYPE_TCPv6 (1 << 4)
|
||||
#define VIRTIO_NET_RSS_HASH_TYPE_UDPv6 (1 << 5)
|
||||
#define VIRTIO_NET_RSS_HASH_TYPE_IP_EX (1 << 6)
|
||||
#define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX (1 << 7)
|
||||
#define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX (1 << 8)
|
||||
|
||||
struct virtio_net_config {
|
||||
/* The config defining mac address (if VIRTIO_NET_F_MAC) */
|
||||
uint8_t mac[ETH_ALEN];
|
||||
@@ -92,6 +106,12 @@ struct virtio_net_config {
|
||||
* Any other value stands for unknown.
|
||||
*/
|
||||
uint8_t duplex;
|
||||
/* maximum size of RSS key */
|
||||
uint8_t rss_max_key_size;
|
||||
/* maximum number of indirection table entries */
|
||||
uint16_t rss_max_indirection_table_length;
|
||||
/* bitmask of supported VIRTIO_NET_RSS_HASH_ types */
|
||||
uint32_t supported_hash_types;
|
||||
} QEMU_PACKED;
|
||||
|
||||
/*
|
||||
@@ -104,6 +124,7 @@ struct virtio_net_config {
|
||||
struct virtio_net_hdr_v1 {
|
||||
#define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 /* Use csum_start, csum_offset */
|
||||
#define VIRTIO_NET_HDR_F_DATA_VALID 2 /* Csum is valid */
|
||||
#define VIRTIO_NET_HDR_F_RSC_INFO 4 /* rsc info in csum_ fields */
|
||||
uint8_t flags;
|
||||
#define VIRTIO_NET_HDR_GSO_NONE 0 /* Not a GSO frame */
|
||||
#define VIRTIO_NET_HDR_GSO_TCPV4 1 /* GSO frame, IPv4 TCP (TSO) */
|
||||
@@ -113,11 +134,46 @@ struct virtio_net_hdr_v1 {
|
||||
uint8_t gso_type;
|
||||
__virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */
|
||||
__virtio16 gso_size; /* Bytes to append to hdr_len per frame */
|
||||
__virtio16 csum_start; /* Position to start checksumming from */
|
||||
__virtio16 csum_offset; /* Offset after that to place checksum */
|
||||
union {
|
||||
struct {
|
||||
__virtio16 csum_start;
|
||||
__virtio16 csum_offset;
|
||||
};
|
||||
/* Checksum calculation */
|
||||
struct {
|
||||
/* Position to start checksumming from */
|
||||
__virtio16 start;
|
||||
/* Offset after that to place checksum */
|
||||
__virtio16 offset;
|
||||
} csum;
|
||||
/* Receive Segment Coalescing */
|
||||
struct {
|
||||
/* Number of coalesced segments */
|
||||
uint16_t segments;
|
||||
/* Number of duplicated acks */
|
||||
uint16_t dup_acks;
|
||||
} rsc;
|
||||
};
|
||||
__virtio16 num_buffers; /* Number of merged rx buffers */
|
||||
};
|
||||
|
||||
struct virtio_net_hdr_v1_hash {
|
||||
struct virtio_net_hdr_v1 hdr;
|
||||
uint32_t hash_value;
|
||||
#define VIRTIO_NET_HASH_REPORT_NONE 0
|
||||
#define VIRTIO_NET_HASH_REPORT_IPv4 1
|
||||
#define VIRTIO_NET_HASH_REPORT_TCPv4 2
|
||||
#define VIRTIO_NET_HASH_REPORT_UDPv4 3
|
||||
#define VIRTIO_NET_HASH_REPORT_IPv6 4
|
||||
#define VIRTIO_NET_HASH_REPORT_TCPv6 5
|
||||
#define VIRTIO_NET_HASH_REPORT_UDPv6 6
|
||||
#define VIRTIO_NET_HASH_REPORT_IPv6_EX 7
|
||||
#define VIRTIO_NET_HASH_REPORT_TCPv6_EX 8
|
||||
#define VIRTIO_NET_HASH_REPORT_UDPv6_EX 9
|
||||
uint16_t hash_report;
|
||||
uint16_t padding;
|
||||
};
|
||||
|
||||
#ifndef VIRTIO_NET_NO_LEGACY
|
||||
/* This header comes first in the scatter-gather list.
|
||||
* For legacy virtio, if VIRTIO_F_ANY_LAYOUT is not negotiated, it must
|
||||
@@ -228,7 +284,9 @@ struct virtio_net_ctrl_mac {
|
||||
|
||||
/*
|
||||
* Control Receive Flow Steering
|
||||
*
|
||||
*/
|
||||
#define VIRTIO_NET_CTRL_MQ 4
|
||||
/*
|
||||
* The command VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET
|
||||
* enables Receive Flow Steering, specifying the number of the transmit and
|
||||
* receive queues that will be used. After the command is consumed and acked by
|
||||
@@ -241,11 +299,47 @@ struct virtio_net_ctrl_mq {
|
||||
__virtio16 virtqueue_pairs;
|
||||
};
|
||||
|
||||
#define VIRTIO_NET_CTRL_MQ 4
|
||||
#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0
|
||||
#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN 1
|
||||
#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX 0x8000
|
||||
|
||||
/*
|
||||
* The command VIRTIO_NET_CTRL_MQ_RSS_CONFIG has the same effect as
|
||||
* VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET does and additionally configures
|
||||
* the receive steering to use a hash calculated for incoming packet
|
||||
* to decide on receive virtqueue to place the packet. The command
|
||||
* also provides parameters to calculate a hash and receive virtqueue.
|
||||
*/
|
||||
struct virtio_net_rss_config {
|
||||
uint32_t hash_types;
|
||||
uint16_t indirection_table_mask;
|
||||
uint16_t unclassified_queue;
|
||||
uint16_t indirection_table[1/* + indirection_table_mask */];
|
||||
uint16_t max_tx_vq;
|
||||
uint8_t hash_key_length;
|
||||
uint8_t hash_key_data[/* hash_key_length */];
|
||||
};
|
||||
|
||||
#define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1
|
||||
|
||||
/*
|
||||
* The command VIRTIO_NET_CTRL_MQ_HASH_CONFIG requests the device
|
||||
* to include in the virtio header of the packet the value of the
|
||||
* calculated hash and the report type of hash. It also provides
|
||||
* parameters for hash calculation. The command requires feature
|
||||
* VIRTIO_NET_F_HASH_REPORT to be negotiated to extend the
|
||||
* layout of virtio header as defined in virtio_net_hdr_v1_hash.
|
||||
*/
|
||||
struct virtio_net_hash_config {
|
||||
uint32_t hash_types;
|
||||
/* for compatibility with virtio_net_rss_config */
|
||||
uint16_t reserved[4];
|
||||
uint8_t hash_key_length;
|
||||
uint8_t hash_key_data[/* hash_key_length */];
|
||||
};
|
||||
|
||||
#define VIRTIO_NET_CTRL_MQ_HASH_CONFIG 2
|
||||
|
||||
/*
|
||||
* Control network offloads
|
||||
*
|
||||
|
||||
@@ -16,3 +16,5 @@ In addition, other licenses may also apply. Please see:
|
||||
Documentation/process/license-rules.rst
|
||||
|
||||
for more details.
|
||||
|
||||
All contributions to the Linux Kernel are subject to this COPYING file.
|
||||
@@ -390,6 +390,7 @@ struct kvm_sync_regs {
|
||||
#define KVM_STATE_NESTED_GUEST_MODE 0x00000001
|
||||
#define KVM_STATE_NESTED_RUN_PENDING 0x00000002
|
||||
#define KVM_STATE_NESTED_EVMCS 0x00000004
|
||||
#define KVM_STATE_NESTED_MTF_PENDING 0x00000008
|
||||
|
||||
#define KVM_STATE_NESTED_SMM_GUEST_MODE 0x00000001
|
||||
#define KVM_STATE_NESTED_SMM_VMXON 0x00000002
|
||||
|
||||
@@ -429,4 +429,5 @@
|
||||
#define __NR_openat2 437
|
||||
#define __NR_pidfd_getfd 438
|
||||
|
||||
|
||||
#endif /* _ASM_X86_UNISTD_32_H */
|
||||
@@ -351,4 +351,5 @@
|
||||
#define __NR_openat2 437
|
||||
#define __NR_pidfd_getfd 438
|
||||
|
||||
|
||||
#endif /* _ASM_X86_UNISTD_64_H */
|
||||
@@ -340,4 +340,5 @@
|
||||
#define __NR_preadv2 (__X32_SYSCALL_BIT + 546)
|
||||
#define __NR_pwritev2 (__X32_SYSCALL_BIT + 547)
|
||||
|
||||
|
||||
#endif /* _ASM_X86_UNISTD_X32_H */
|
||||
@@ -474,12 +474,17 @@ struct kvm_s390_mem_op {
|
||||
__u32 size; /* amount of bytes */
|
||||
__u32 op; /* type of operation */
|
||||
__u64 buf; /* buffer in userspace */
|
||||
__u8 ar; /* the access register number */
|
||||
__u8 reserved[31]; /* should be set to 0 */
|
||||
union {
|
||||
__u8 ar; /* the access register number */
|
||||
__u32 sida_offset; /* offset into the sida */
|
||||
__u8 reserved[32]; /* should be set to 0 */
|
||||
};
|
||||
};
|
||||
/* types for kvm_s390_mem_op->op */
|
||||
#define KVM_S390_MEMOP_LOGICAL_READ 0
|
||||
#define KVM_S390_MEMOP_LOGICAL_WRITE 1
|
||||
#define KVM_S390_MEMOP_SIDA_READ 2
|
||||
#define KVM_S390_MEMOP_SIDA_WRITE 3
|
||||
/* flags for kvm_s390_mem_op->flags */
|
||||
#define KVM_S390_MEMOP_F_CHECK_ONLY (1ULL << 0)
|
||||
#define KVM_S390_MEMOP_F_INJECT_EXCEPTION (1ULL << 1)
|
||||
@@ -1010,6 +1015,8 @@ struct kvm_ppc_resize_hpt {
|
||||
#define KVM_CAP_ARM_NISV_TO_USER 177
|
||||
#define KVM_CAP_ARM_INJECT_EXT_DABT 178
|
||||
#define KVM_CAP_S390_VCPU_RESETS 179
|
||||
#define KVM_CAP_S390_PROTECTED 180
|
||||
#define KVM_CAP_PPC_SECURE_GUEST 181
|
||||
|
||||
#ifdef KVM_CAP_IRQ_ROUTING
|
||||
|
||||
@@ -1478,6 +1485,39 @@ struct kvm_enc_region {
|
||||
#define KVM_S390_NORMAL_RESET _IO(KVMIO, 0xc3)
|
||||
#define KVM_S390_CLEAR_RESET _IO(KVMIO, 0xc4)
|
||||
|
||||
struct kvm_s390_pv_sec_parm {
|
||||
__u64 origin;
|
||||
__u64 length;
|
||||
};
|
||||
|
||||
struct kvm_s390_pv_unp {
|
||||
__u64 addr;
|
||||
__u64 size;
|
||||
__u64 tweak;
|
||||
};
|
||||
|
||||
enum pv_cmd_id {
|
||||
KVM_PV_ENABLE,
|
||||
KVM_PV_DISABLE,
|
||||
KVM_PV_SET_SEC_PARMS,
|
||||
KVM_PV_UNPACK,
|
||||
KVM_PV_VERIFY,
|
||||
KVM_PV_PREP_RESET,
|
||||
KVM_PV_UNSHARE_ALL,
|
||||
};
|
||||
|
||||
struct kvm_pv_cmd {
|
||||
__u32 cmd; /* Command to be executed */
|
||||
__u16 rc; /* Ultravisor return code */
|
||||
__u16 rrc; /* Ultravisor return reason code */
|
||||
__u64 data; /* Data or address */
|
||||
__u32 flags; /* flags for future extensions. Must be 0 for now */
|
||||
__u32 reserved[3];
|
||||
};
|
||||
|
||||
/* Available with KVM_CAP_S390_PROTECTED */
|
||||
#define KVM_S390_PV_COMMAND _IOWR(KVMIO, 0xc5, struct kvm_pv_cmd)
|
||||
|
||||
/* Secure Encrypted Virtualization command */
|
||||
enum sev_cmd_id {
|
||||
/* Guest initialization commands */
|
||||
@@ -1628,4 +1668,7 @@ struct kvm_hyperv_eventfd {
|
||||
#define KVM_HYPERV_CONN_ID_MASK 0x00ffffff
|
||||
#define KVM_HYPERV_EVENTFD_DEASSIGN (1 << 0)
|
||||
|
||||
#define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (1 << 0)
|
||||
#define KVM_DIRTY_LOG_INITIALLY_SET (1 << 1)
|
||||
|
||||
#endif /* __LINUX_KVM_H */
|
||||
@@ -5,8 +5,9 @@
|
||||
#include <asm/mman.h>
|
||||
#include <asm-generic/hugetlb_encode.h>
|
||||
|
||||
#define MREMAP_MAYMOVE 1
|
||||
#define MREMAP_FIXED 2
|
||||
#define MREMAP_MAYMOVE 1
|
||||
#define MREMAP_FIXED 2
|
||||
#define MREMAP_DONTUNMAP 4
|
||||
|
||||
#define OVERCOMMIT_GUESS 0
|
||||
#define OVERCOMMIT_ALWAYS 1
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
* means the userland is reading).
|
||||
*/
|
||||
#define UFFD_API ((__u64)0xAA)
|
||||
#define UFFD_API_FEATURES (UFFD_FEATURE_EVENT_FORK | \
|
||||
#define UFFD_API_FEATURES (UFFD_FEATURE_PAGEFAULT_FLAG_WP | \
|
||||
UFFD_FEATURE_EVENT_FORK | \
|
||||
UFFD_FEATURE_EVENT_REMAP | \
|
||||
UFFD_FEATURE_EVENT_REMOVE | \
|
||||
UFFD_FEATURE_EVENT_UNMAP | \
|
||||
@@ -34,7 +35,8 @@
|
||||
#define UFFD_API_RANGE_IOCTLS \
|
||||
((__u64)1 << _UFFDIO_WAKE | \
|
||||
(__u64)1 << _UFFDIO_COPY | \
|
||||
(__u64)1 << _UFFDIO_ZEROPAGE)
|
||||
(__u64)1 << _UFFDIO_ZEROPAGE | \
|
||||
(__u64)1 << _UFFDIO_WRITEPROTECT)
|
||||
#define UFFD_API_RANGE_IOCTLS_BASIC \
|
||||
((__u64)1 << _UFFDIO_WAKE | \
|
||||
(__u64)1 << _UFFDIO_COPY)
|
||||
@@ -52,6 +54,7 @@
|
||||
#define _UFFDIO_WAKE (0x02)
|
||||
#define _UFFDIO_COPY (0x03)
|
||||
#define _UFFDIO_ZEROPAGE (0x04)
|
||||
#define _UFFDIO_WRITEPROTECT (0x06)
|
||||
#define _UFFDIO_API (0x3F)
|
||||
|
||||
/* userfaultfd ioctl ids */
|
||||
@@ -68,6 +71,8 @@
|
||||
struct uffdio_copy)
|
||||
#define UFFDIO_ZEROPAGE _IOWR(UFFDIO, _UFFDIO_ZEROPAGE, \
|
||||
struct uffdio_zeropage)
|
||||
#define UFFDIO_WRITEPROTECT _IOWR(UFFDIO, _UFFDIO_WRITEPROTECT, \
|
||||
struct uffdio_writeprotect)
|
||||
|
||||
/* read() structure */
|
||||
struct uffd_msg {
|
||||
@@ -203,13 +208,14 @@ struct uffdio_copy {
|
||||
__u64 dst;
|
||||
__u64 src;
|
||||
__u64 len;
|
||||
/*
|
||||
* There will be a wrprotection flag later that allows to map
|
||||
* pages wrprotected on the fly. And such a flag will be
|
||||
* available if the wrprotection ioctl are implemented for the
|
||||
* range according to the uffdio_register.ioctls.
|
||||
*/
|
||||
#define UFFDIO_COPY_MODE_DONTWAKE ((__u64)1<<0)
|
||||
/*
|
||||
* UFFDIO_COPY_MODE_WP will map the page write protected on
|
||||
* the fly. UFFDIO_COPY_MODE_WP is available only if the
|
||||
* write protected ioctl is implemented for the range
|
||||
* according to the uffdio_register.ioctls.
|
||||
*/
|
||||
#define UFFDIO_COPY_MODE_WP ((__u64)1<<1)
|
||||
__u64 mode;
|
||||
|
||||
/*
|
||||
@@ -231,4 +237,24 @@ struct uffdio_zeropage {
|
||||
__s64 zeropage;
|
||||
};
|
||||
|
||||
struct uffdio_writeprotect {
|
||||
struct uffdio_range range;
|
||||
/*
|
||||
* UFFDIO_WRITEPROTECT_MODE_WP: set the flag to write protect a range,
|
||||
* unset the flag to undo protection of a range which was previously
|
||||
* write protected.
|
||||
*
|
||||
* UFFDIO_WRITEPROTECT_MODE_DONTWAKE: set the flag to avoid waking up
|
||||
* any wait thread after the operation succeeds.
|
||||
*
|
||||
* NOTE: Write protecting a region (WP=1) is unrelated to page faults,
|
||||
* therefore DONTWAKE flag is meaningless with WP=1. Removing write
|
||||
* protection (WP=0) in response to a page fault wakes the faulting
|
||||
* task unless DONTWAKE is set.
|
||||
*/
|
||||
#define UFFDIO_WRITEPROTECT_MODE_WP ((__u64)1<<0)
|
||||
#define UFFDIO_WRITEPROTECT_MODE_DONTWAKE ((__u64)1<<1)
|
||||
__u64 mode;
|
||||
};
|
||||
|
||||
#endif /* _LINUX_USERFAULTFD_H */
|
||||
@@ -707,6 +707,43 @@ struct vfio_device_ioeventfd {
|
||||
|
||||
#define VFIO_DEVICE_IOEVENTFD _IO(VFIO_TYPE, VFIO_BASE + 16)
|
||||
|
||||
/**
|
||||
* VFIO_DEVICE_FEATURE - _IORW(VFIO_TYPE, VFIO_BASE + 17,
|
||||
* struct vfio_device_feature)
|
||||
*
|
||||
* Get, set, or probe feature data of the device. The feature is selected
|
||||
* using the FEATURE_MASK portion of the flags field. Support for a feature
|
||||
* can be probed by setting both the FEATURE_MASK and PROBE bits. A probe
|
||||
* may optionally include the GET and/or SET bits to determine read vs write
|
||||
* access of the feature respectively. Probing a feature will return success
|
||||
* if the feature is supported and all of the optionally indicated GET/SET
|
||||
* methods are supported. The format of the data portion of the structure is
|
||||
* specific to the given feature. The data portion is not required for
|
||||
* probing. GET and SET are mutually exclusive, except for use with PROBE.
|
||||
*
|
||||
* Return 0 on success, -errno on failure.
|
||||
*/
|
||||
struct vfio_device_feature {
|
||||
__u32 argsz;
|
||||
__u32 flags;
|
||||
#define VFIO_DEVICE_FEATURE_MASK (0xffff) /* 16-bit feature index */
|
||||
#define VFIO_DEVICE_FEATURE_GET (1 << 16) /* Get feature into data[] */
|
||||
#define VFIO_DEVICE_FEATURE_SET (1 << 17) /* Set feature from data[] */
|
||||
#define VFIO_DEVICE_FEATURE_PROBE (1 << 18) /* Probe feature support */
|
||||
__u8 data[];
|
||||
};
|
||||
|
||||
#define VFIO_DEVICE_FEATURE _IO(VFIO_TYPE, VFIO_BASE + 17)
|
||||
|
||||
/*
|
||||
* Provide support for setting a PCI VF Token, which is used as a shared
|
||||
* secret between PF and VF drivers. This feature may only be set on a
|
||||
* PCI SR-IOV PF when SR-IOV is enabled on the PF and there are no existing
|
||||
* open VFs. Data provided when setting this feature is a 16-byte array
|
||||
* (__u8 b[16]), representing a UUID.
|
||||
*/
|
||||
#define VFIO_DEVICE_FEATURE_PCI_VF_TOKEN (0)
|
||||
|
||||
/* -------- API for Type1 VFIO IOMMU -------- */
|
||||
|
||||
/**
|
||||
|
||||
@@ -116,4 +116,28 @@
|
||||
#define VHOST_VSOCK_SET_GUEST_CID _IOW(VHOST_VIRTIO, 0x60, __u64)
|
||||
#define VHOST_VSOCK_SET_RUNNING _IOW(VHOST_VIRTIO, 0x61, int)
|
||||
|
||||
/* VHOST_VDPA specific defines */
|
||||
|
||||
/* Get the device id. The device ids follow the same definition of
|
||||
* the device id defined in virtio-spec.
|
||||
*/
|
||||
#define VHOST_VDPA_GET_DEVICE_ID _IOR(VHOST_VIRTIO, 0x70, __u32)
|
||||
/* Get and set the status. The status bits follow the same definition
|
||||
* of the device status defined in virtio-spec.
|
||||
*/
|
||||
#define VHOST_VDPA_GET_STATUS _IOR(VHOST_VIRTIO, 0x71, __u8)
|
||||
#define VHOST_VDPA_SET_STATUS _IOW(VHOST_VIRTIO, 0x72, __u8)
|
||||
/* Get and set the device config. The device config follows the same
|
||||
* definition of the device config defined in virtio-spec.
|
||||
*/
|
||||
#define VHOST_VDPA_GET_CONFIG _IOR(VHOST_VIRTIO, 0x73, \
|
||||
struct vhost_vdpa_config)
|
||||
#define VHOST_VDPA_SET_CONFIG _IOW(VHOST_VIRTIO, 0x74, \
|
||||
struct vhost_vdpa_config)
|
||||
/* Enable/disable the ring. */
|
||||
#define VHOST_VDPA_SET_VRING_ENABLE _IOW(VHOST_VIRTIO, 0x75, \
|
||||
struct vhost_vring_state)
|
||||
/* Get the max ring size. */
|
||||
#define VHOST_VDPA_GET_VRING_NUM _IOR(VHOST_VIRTIO, 0x76, __u16)
|
||||
|
||||
#endif
|
||||
@@ -125,10 +125,10 @@
|
||||
{ TARGET_NR_dup3, "dup3" , "%s(%d,%d,%d)", NULL, NULL },
|
||||
#endif
|
||||
#ifdef TARGET_NR_epoll_create
|
||||
{ TARGET_NR_epoll_create, "%s(%d)", NULL, NULL, NULL },
|
||||
{ TARGET_NR_epoll_create, "epoll_create", "%s(%d)", NULL, NULL },
|
||||
#endif
|
||||
#ifdef TARGET_NR_epoll_create1
|
||||
{ TARGET_NR_epoll_create1, "%s(%d)", NULL, NULL, NULL },
|
||||
{ TARGET_NR_epoll_create1, "epoll_create1", "%s(%d)", NULL, NULL },
|
||||
#endif
|
||||
#ifdef TARGET_NR_epoll_ctl
|
||||
{ TARGET_NR_epoll_ctl, "epoll_ctl" , NULL, NULL, NULL },
|
||||
|
||||
@@ -1352,35 +1352,24 @@ bool memory_region_access_valid(MemoryRegion *mr,
|
||||
bool is_write,
|
||||
MemTxAttrs attrs)
|
||||
{
|
||||
int access_size_min, access_size_max;
|
||||
int access_size, i;
|
||||
if (mr->ops->valid.accepts
|
||||
&& !mr->ops->valid.accepts(mr->opaque, addr, size, is_write, attrs)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mr->ops->valid.unaligned && (addr & (size - 1))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mr->ops->valid.accepts) {
|
||||
/* Treat zero as compatibility all valid */
|
||||
if (!mr->ops->valid.max_access_size) {
|
||||
return true;
|
||||
}
|
||||
|
||||
access_size_min = mr->ops->valid.min_access_size;
|
||||
if (!mr->ops->valid.min_access_size) {
|
||||
access_size_min = 1;
|
||||
if (size > mr->ops->valid.max_access_size
|
||||
|| size < mr->ops->valid.min_access_size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
access_size_max = mr->ops->valid.max_access_size;
|
||||
if (!mr->ops->valid.max_access_size) {
|
||||
access_size_max = 4;
|
||||
}
|
||||
|
||||
access_size = MAX(MIN(size, access_size_max), access_size_min);
|
||||
for (i = 0; i < size; i += access_size) {
|
||||
if (!mr->ops->valid.accepts(mr->opaque, addr + i, access_size,
|
||||
is_write, attrs)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -498,7 +498,7 @@ void dirty_bitmap_mig_before_vm_start(void)
|
||||
DirtyBitmapLoadBitmapState *b = item->data;
|
||||
|
||||
if (b->migrated) {
|
||||
bdrv_enable_dirty_bitmap_locked(b->bitmap);
|
||||
bdrv_enable_dirty_bitmap(b->bitmap);
|
||||
} else {
|
||||
bdrv_dirty_bitmap_enable_successor(b->bitmap);
|
||||
}
|
||||
|
||||
+43
-8
@@ -217,7 +217,7 @@ nbd_negotiate_send_rep_verr(NBDClient *client, uint32_t type,
|
||||
|
||||
msg = g_strdup_vprintf(fmt, va);
|
||||
len = strlen(msg);
|
||||
assert(len < 4096);
|
||||
assert(len < NBD_MAX_STRING_SIZE);
|
||||
trace_nbd_negotiate_send_rep_err(msg);
|
||||
ret = nbd_negotiate_send_rep_len(client, type, len, errp);
|
||||
if (ret < 0) {
|
||||
@@ -231,6 +231,19 @@ nbd_negotiate_send_rep_verr(NBDClient *client, uint32_t type,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a malloc'd copy of @name suitable for use in an error reply.
|
||||
*/
|
||||
static char *
|
||||
nbd_sanitize_name(const char *name)
|
||||
{
|
||||
if (strnlen(name, 80) < 80) {
|
||||
return g_strdup(name);
|
||||
}
|
||||
/* XXX Should we also try to sanitize any control characters? */
|
||||
return g_strdup_printf("%.80s...", name);
|
||||
}
|
||||
|
||||
/* Send an error reply.
|
||||
* Return -errno on error, 0 on success. */
|
||||
static int GCC_FMT_ATTR(4, 5)
|
||||
@@ -595,9 +608,11 @@ static int nbd_negotiate_handle_info(NBDClient *client, Error **errp)
|
||||
|
||||
exp = nbd_export_find(name);
|
||||
if (!exp) {
|
||||
g_autofree char *sane_name = nbd_sanitize_name(name);
|
||||
|
||||
return nbd_negotiate_send_rep_err(client, NBD_REP_ERR_UNKNOWN,
|
||||
errp, "export '%s' not present",
|
||||
name);
|
||||
sane_name);
|
||||
}
|
||||
|
||||
/* Don't bother sending NBD_INFO_NAME unless client requested it */
|
||||
@@ -995,8 +1010,10 @@ static int nbd_negotiate_meta_queries(NBDClient *client,
|
||||
|
||||
meta->exp = nbd_export_find(export_name);
|
||||
if (meta->exp == NULL) {
|
||||
g_autofree char *sane_name = nbd_sanitize_name(export_name);
|
||||
|
||||
return nbd_opt_drop(client, NBD_REP_ERR_UNKNOWN, errp,
|
||||
"export '%s' not present", export_name);
|
||||
"export '%s' not present", sane_name);
|
||||
}
|
||||
|
||||
ret = nbd_opt_read(client, &nb_queries, sizeof(nb_queries), errp);
|
||||
@@ -2348,8 +2365,17 @@ static coroutine_fn int nbd_handle_request(NBDClient *client,
|
||||
if (request->flags & NBD_CMD_FLAG_FAST_ZERO) {
|
||||
flags |= BDRV_REQ_NO_FALLBACK;
|
||||
}
|
||||
ret = blk_pwrite_zeroes(exp->blk, request->from + exp->dev_offset,
|
||||
request->len, flags);
|
||||
ret = 0;
|
||||
/* FIXME simplify this when blk_pwrite_zeroes switches to 64-bit */
|
||||
while (ret >= 0 && request->len) {
|
||||
int align = client->check_align ?: 1;
|
||||
int len = MIN(request->len, QEMU_ALIGN_DOWN(BDRV_REQUEST_MAX_BYTES,
|
||||
align));
|
||||
ret = blk_pwrite_zeroes(exp->blk, request->from + exp->dev_offset,
|
||||
len, flags);
|
||||
request->len -= len;
|
||||
request->from += len;
|
||||
}
|
||||
return nbd_send_generic_reply(client, request->handle, ret,
|
||||
"writing to file failed", errp);
|
||||
|
||||
@@ -2363,9 +2389,18 @@ static coroutine_fn int nbd_handle_request(NBDClient *client,
|
||||
"flush failed", errp);
|
||||
|
||||
case NBD_CMD_TRIM:
|
||||
ret = blk_co_pdiscard(exp->blk, request->from + exp->dev_offset,
|
||||
request->len);
|
||||
if (ret == 0 && request->flags & NBD_CMD_FLAG_FUA) {
|
||||
ret = 0;
|
||||
/* FIXME simplify this when blk_co_pdiscard switches to 64-bit */
|
||||
while (ret >= 0 && request->len) {
|
||||
int align = client->check_align ?: 1;
|
||||
int len = MIN(request->len, QEMU_ALIGN_DOWN(BDRV_REQUEST_MAX_BYTES,
|
||||
align));
|
||||
ret = blk_co_pdiscard(exp->blk, request->from + exp->dev_offset,
|
||||
len);
|
||||
request->len -= len;
|
||||
request->from += len;
|
||||
}
|
||||
if (ret >= 0 && request->flags & NBD_CMD_FLAG_FUA) {
|
||||
ret = blk_co_flush(exp->blk);
|
||||
}
|
||||
return nbd_send_generic_reply(client, request->handle, ret,
|
||||
|
||||
@@ -610,7 +610,7 @@ void qemu_flush_or_purge_queued_packets(NetClientState *nc, bool purge)
|
||||
qemu_notify_event();
|
||||
} else if (purge) {
|
||||
/* Unable to empty the queue, purge remaining packets */
|
||||
qemu_net_queue_purge(nc->incoming_queue, nc);
|
||||
qemu_net_queue_purge(nc->incoming_queue, nc->peer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1506,7 +1506,7 @@ static int net_param_nic(void *dummy, QemuOpts *opts, Error **errp)
|
||||
/* Create an ID if the user did not specify one */
|
||||
nd_id = g_strdup(qemu_opts_id(opts));
|
||||
if (!nd_id) {
|
||||
nd_id = g_strdup_printf("__org.qemu.nic%i\n", idx);
|
||||
nd_id = g_strdup_printf("__org.qemu.nic%i", idx);
|
||||
qemu_opts_set_id(opts, nd_id);
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1
-1
@@ -299,7 +299,7 @@ int qdev_device_help(QemuOpts *opts)
|
||||
}
|
||||
g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0);
|
||||
for (i = 0; i < array->len; i++) {
|
||||
printf("%s\n", (char *)array->pdata[i]);
|
||||
qemu_printf("%s\n", (char *)array->pdata[i]);
|
||||
}
|
||||
g_ptr_array_set_free_func(array, g_free);
|
||||
g_ptr_array_free(array, true);
|
||||
|
||||
+8
-5
@@ -856,8 +856,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
tlscreds = nbd_get_tls_creds(tlscredsid, list, &local_err);
|
||||
if (local_err) {
|
||||
error_report("Failed to get TLS creds %s",
|
||||
error_get_pretty(local_err));
|
||||
error_reportf_err(local_err, "Failed to get TLS creds: ");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
} else {
|
||||
@@ -916,7 +915,11 @@ int main(int argc, char **argv)
|
||||
} else if (pid == 0) {
|
||||
close(stderr_fd[0]);
|
||||
|
||||
old_stderr = dup(STDERR_FILENO);
|
||||
/* Remember parent's stderr if we will be restoring it. */
|
||||
if (fork_process) {
|
||||
old_stderr = dup(STDERR_FILENO);
|
||||
}
|
||||
|
||||
ret = qemu_daemon(1, 0);
|
||||
|
||||
/* Temporarily redirect stderr to the parent's pipe... */
|
||||
@@ -979,8 +982,8 @@ int main(int argc, char **argv)
|
||||
&local_err);
|
||||
if (sioc == NULL) {
|
||||
object_unref(OBJECT(server));
|
||||
error_report("Failed to use socket activation: %s",
|
||||
error_get_pretty(local_err));
|
||||
error_reportf_err(local_err,
|
||||
"Failed to use socket activation: ");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
qio_net_listener_add(server, sioc);
|
||||
|
||||
+13
-4
@@ -515,11 +515,20 @@ int ga_parse_whence(GuestFileWhence *whence, Error **errp)
|
||||
GuestHostName *qmp_guest_get_host_name(Error **errp)
|
||||
{
|
||||
GuestHostName *result = NULL;
|
||||
gchar const *hostname = g_get_host_name();
|
||||
if (hostname != NULL) {
|
||||
result = g_new0(GuestHostName, 1);
|
||||
result->host_name = g_strdup(hostname);
|
||||
g_autofree char *hostname = qemu_get_host_name(errp);
|
||||
|
||||
/*
|
||||
* We want to avoid using g_get_host_name() because that
|
||||
* caches the result and we wouldn't reflect changes in the
|
||||
* host name.
|
||||
*/
|
||||
|
||||
if (!hostname) {
|
||||
hostname = g_strdup("localhost");
|
||||
}
|
||||
|
||||
result = g_new0(GuestHostName, 1);
|
||||
result->host_name = g_steal_pointer(&hostname);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -531,7 +531,11 @@ static int send_response(GAState *s, const QDict *rsp)
|
||||
QString *payload_qstr, *response_qstr;
|
||||
GIOStatus status;
|
||||
|
||||
g_assert(rsp && s->channel);
|
||||
g_assert(s->channel);
|
||||
|
||||
if (!rsp) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
payload_qstr = qobject_to_json(QOBJECT(rsp));
|
||||
if (!payload_qstr) {
|
||||
|
||||
+1
-1
Submodule roms/openbios updated: 7e5b89e429...7f28286f5c.
@@ -1030,8 +1030,8 @@ int main(int argc, char **argv)
|
||||
server_ioc = qio_channel_socket_new_fd(FIRST_SOCKET_ACTIVATION_FD,
|
||||
&local_err);
|
||||
if (server_ioc == NULL) {
|
||||
error_report("Failed to use socket activation: %s",
|
||||
error_get_pretty(local_err));
|
||||
error_reportf_err(local_err,
|
||||
"Failed to use socket activation: ");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -737,6 +737,7 @@ void HELPER(NAME)(void *vd, void *vn, void *vm, void *stat, uint32_t desc) \
|
||||
d[i + j] = TYPE##_mul(n[i + j], mm, stat); \
|
||||
} \
|
||||
} \
|
||||
clear_tail(d, oprsz, simd_maxsz(desc)); \
|
||||
}
|
||||
|
||||
DO_MUL_IDX(gvec_fmul_idx_h, float16, H2)
|
||||
@@ -761,6 +762,7 @@ void HELPER(NAME)(void *vd, void *vn, void *vm, void *va, \
|
||||
mm, a[i + j], 0, stat); \
|
||||
} \
|
||||
} \
|
||||
clear_tail(d, oprsz, simd_maxsz(desc)); \
|
||||
}
|
||||
|
||||
DO_FMLA_IDX(gvec_fmla_idx_h, float16, H2)
|
||||
|
||||
@@ -1294,6 +1294,8 @@ static void do_sub(DisasContext *ctx, unsigned rt, TCGv_reg in1,
|
||||
save_or_nullify(ctx, cpu_psw_cb_msb, cb_msb);
|
||||
save_gpr(ctx, rt, dest);
|
||||
tcg_temp_free(dest);
|
||||
tcg_temp_free(cb);
|
||||
tcg_temp_free(cb_msb);
|
||||
|
||||
/* Install the new nullification. */
|
||||
cond_free(&ctx->null_cond);
|
||||
|
||||
@@ -6491,6 +6491,9 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
|
||||
host_cpuid(5, 0, &cpu->mwait.eax, &cpu->mwait.ebx,
|
||||
&cpu->mwait.ecx, &cpu->mwait.edx);
|
||||
env->features[FEAT_1_ECX] |= CPUID_EXT_MONITOR;
|
||||
if (kvm_enabled() && kvm_has_waitpkg()) {
|
||||
env->features[FEAT_7_0_ECX] |= CPUID_7_0_ECX_WAITPKG;
|
||||
}
|
||||
}
|
||||
if (kvm_enabled() && cpu->ucode_rev == 0) {
|
||||
cpu->ucode_rev = kvm_arch_get_supported_msr_feature(kvm_state,
|
||||
|
||||
+5
-6
@@ -407,12 +407,6 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
|
||||
if (host_tsx_blacklisted()) {
|
||||
ret &= ~(CPUID_7_0_EBX_RTM | CPUID_7_0_EBX_HLE);
|
||||
}
|
||||
} else if (function == 7 && index == 0 && reg == R_ECX) {
|
||||
if (enable_cpu_pm) {
|
||||
ret |= CPUID_7_0_ECX_WAITPKG;
|
||||
} else {
|
||||
ret &= ~CPUID_7_0_ECX_WAITPKG;
|
||||
}
|
||||
} else if (function == 7 && index == 0 && reg == R_EDX) {
|
||||
/*
|
||||
* Linux v4.17-v4.20 incorrectly return ARCH_CAPABILITIES on SVM hosts.
|
||||
@@ -4678,3 +4672,8 @@ int kvm_arch_msi_data_to_gsi(uint32_t data)
|
||||
{
|
||||
abort();
|
||||
}
|
||||
|
||||
bool kvm_has_waitpkg(void)
|
||||
{
|
||||
return has_msr_umwait;
|
||||
}
|
||||
@@ -44,6 +44,7 @@ void kvm_put_apicbase(X86CPU *cpu, uint64_t value);
|
||||
|
||||
bool kvm_enable_x2apic(void);
|
||||
bool kvm_has_x2apic_api(void);
|
||||
bool kvm_has_waitpkg(void);
|
||||
|
||||
bool kvm_hv_vpindex_settable(void);
|
||||
|
||||
|
||||
@@ -69,13 +69,15 @@ def pick_default_qemu_bin(arch=None):
|
||||
|
||||
|
||||
def _console_interaction(test, success_message, failure_message,
|
||||
send_string, keep_sending=False):
|
||||
send_string, keep_sending=False, vm=None):
|
||||
assert not keep_sending or send_string
|
||||
console = test.vm.console_socket.makefile()
|
||||
if vm is None:
|
||||
vm = test.vm
|
||||
console = vm.console_socket.makefile()
|
||||
console_logger = logging.getLogger('console')
|
||||
while True:
|
||||
if send_string:
|
||||
test.vm.console_socket.sendall(send_string.encode())
|
||||
vm.console_socket.sendall(send_string.encode())
|
||||
if not keep_sending:
|
||||
send_string = None # send only once
|
||||
msg = console.readline().strip()
|
||||
@@ -115,7 +117,8 @@ def interrupt_interactive_console_until_pattern(test, success_message,
|
||||
_console_interaction(test, success_message, failure_message,
|
||||
interrupt_string, True)
|
||||
|
||||
def wait_for_console_pattern(test, success_message, failure_message=None):
|
||||
def wait_for_console_pattern(test, success_message, failure_message=None,
|
||||
vm=None):
|
||||
"""
|
||||
Waits for messages to appear on the console, while logging the content
|
||||
|
||||
@@ -125,7 +128,7 @@ def wait_for_console_pattern(test, success_message, failure_message=None):
|
||||
:param success_message: if this message appears, test succeeds
|
||||
:param failure_message: if this message appears, test fails
|
||||
"""
|
||||
_console_interaction(test, success_message, failure_message, None)
|
||||
_console_interaction(test, success_message, failure_message, None, vm=vm)
|
||||
|
||||
def exec_command_and_wait_for_pattern(test, command,
|
||||
success_message, failure_message=None):
|
||||
|
||||
@@ -26,22 +26,8 @@ KVM_NOT_AVAILABLE = ACCEL_NOT_AVAILABLE_FMT % "KVM"
|
||||
TCG_NOT_AVAILABLE = ACCEL_NOT_AVAILABLE_FMT % "TCG"
|
||||
|
||||
|
||||
class BootLinux(Test):
|
||||
"""
|
||||
Boots a Linux system, checking for a successful initialization
|
||||
"""
|
||||
|
||||
timeout = 900
|
||||
chksum = None
|
||||
|
||||
def setUp(self):
|
||||
super(BootLinux, self).setUp()
|
||||
self.vm.add_args('-smp', '2')
|
||||
self.vm.add_args('-m', '1024')
|
||||
self.prepare_boot()
|
||||
self.prepare_cloudinit()
|
||||
|
||||
def prepare_boot(self):
|
||||
class BootLinuxBase(Test):
|
||||
def download_boot(self):
|
||||
self.log.debug('Looking for and selecting a qemu-img binary to be '
|
||||
'used to create the bootable snapshot image')
|
||||
# If qemu-img has been built, use it, otherwise the system wide one
|
||||
@@ -60,17 +46,17 @@ class BootLinux(Test):
|
||||
if image_arch == 'ppc64':
|
||||
image_arch = 'ppc64le'
|
||||
try:
|
||||
self.boot = vmimage.get(
|
||||
boot = vmimage.get(
|
||||
'fedora', arch=image_arch, version='31',
|
||||
checksum=self.chksum,
|
||||
algorithm='sha256',
|
||||
cache_dir=self.cache_dirs[0],
|
||||
snapshot_dir=self.workdir)
|
||||
self.vm.add_args('-drive', 'file=%s' % self.boot.path)
|
||||
except:
|
||||
self.cancel('Failed to download/prepare boot image')
|
||||
return boot.path
|
||||
|
||||
def prepare_cloudinit(self):
|
||||
def download_cloudinit(self):
|
||||
self.log.info('Preparing cloudinit image')
|
||||
try:
|
||||
cloudinit_iso = os.path.join(self.workdir, 'cloudinit.iso')
|
||||
@@ -81,9 +67,32 @@ class BootLinux(Test):
|
||||
# QEMU's hard coded usermode router address
|
||||
phone_home_host='10.0.2.2',
|
||||
phone_home_port=self.phone_home_port)
|
||||
self.vm.add_args('-drive', 'file=%s,format=raw' % cloudinit_iso)
|
||||
except Exception:
|
||||
self.cancel('Failed to prepared cloudinit image')
|
||||
return cloudinit_iso
|
||||
|
||||
class BootLinux(BootLinuxBase):
|
||||
"""
|
||||
Boots a Linux system, checking for a successful initialization
|
||||
"""
|
||||
|
||||
timeout = 900
|
||||
chksum = None
|
||||
|
||||
def setUp(self):
|
||||
super(BootLinux, self).setUp()
|
||||
self.vm.add_args('-smp', '2')
|
||||
self.vm.add_args('-m', '1024')
|
||||
self.prepare_boot()
|
||||
self.prepare_cloudinit()
|
||||
|
||||
def prepare_boot(self):
|
||||
path = self.download_boot()
|
||||
self.vm.add_args('-drive', 'file=%s' % path)
|
||||
|
||||
def prepare_cloudinit(self):
|
||||
cloudinit_iso = self.download_cloudinit()
|
||||
self.vm.add_args('-drive', 'file=%s,format=raw' % cloudinit_iso)
|
||||
|
||||
def launch_and_wait(self):
|
||||
self.vm.set_console()
|
||||
|
||||
@@ -28,19 +28,29 @@ try:
|
||||
except CmdNotFoundError:
|
||||
P7ZIP_AVAILABLE = False
|
||||
|
||||
class BootLinuxConsole(Test):
|
||||
"""
|
||||
Boots a Linux kernel and checks that the console is operational and the
|
||||
kernel command line is properly passed from QEMU to the kernel
|
||||
"""
|
||||
"""
|
||||
Round up to next power of 2
|
||||
"""
|
||||
def pow2ceil(x):
|
||||
return 1 if x == 0 else 2**(x - 1).bit_length()
|
||||
|
||||
timeout = 90
|
||||
"""
|
||||
Expand file size to next power of 2
|
||||
"""
|
||||
def image_pow2ceil_expand(path):
|
||||
size = os.path.getsize(path)
|
||||
size_aligned = pow2ceil(size)
|
||||
if size != size_aligned:
|
||||
with open(path, 'ab+') as fd:
|
||||
fd.truncate(size_aligned)
|
||||
|
||||
class LinuxKernelTest(Test):
|
||||
KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
|
||||
|
||||
def wait_for_console_pattern(self, success_message):
|
||||
def wait_for_console_pattern(self, success_message, vm=None):
|
||||
wait_for_console_pattern(self, success_message,
|
||||
failure_message='Kernel panic - not syncing')
|
||||
failure_message='Kernel panic - not syncing',
|
||||
vm=vm)
|
||||
|
||||
def extract_from_deb(self, deb, path):
|
||||
"""
|
||||
@@ -79,6 +89,13 @@ class BootLinuxConsole(Test):
|
||||
os.chdir(cwd)
|
||||
return os.path.normpath(os.path.join(self.workdir, path))
|
||||
|
||||
class BootLinuxConsole(LinuxKernelTest):
|
||||
"""
|
||||
Boots a Linux kernel and checks that the console is operational and the
|
||||
kernel command line is properly passed from QEMU to the kernel
|
||||
"""
|
||||
timeout = 90
|
||||
|
||||
def test_x86_64_pc(self):
|
||||
"""
|
||||
:avocado: tags=arch:x86_64
|
||||
@@ -583,6 +600,7 @@ class BootLinuxConsole(Test):
|
||||
"""
|
||||
:avocado: tags=arch:arm
|
||||
:avocado: tags=machine:orangepi-pc
|
||||
:avocado: tags=device:sd
|
||||
"""
|
||||
deb_url = ('https://apt.armbian.com/pool/main/l/'
|
||||
'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
|
||||
@@ -598,6 +616,7 @@ class BootLinuxConsole(Test):
|
||||
rootfs_path_xz = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash)
|
||||
rootfs_path = os.path.join(self.workdir, 'rootfs.cpio')
|
||||
archive.lzma_uncompress(rootfs_path_xz, rootfs_path)
|
||||
image_pow2ceil_expand(rootfs_path)
|
||||
|
||||
self.vm.set_console()
|
||||
kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
|
||||
@@ -632,9 +651,10 @@ class BootLinuxConsole(Test):
|
||||
"""
|
||||
:avocado: tags=arch:arm
|
||||
:avocado: tags=machine:orangepi-pc
|
||||
:avocado: tags=device:sd
|
||||
"""
|
||||
|
||||
# This test download a 196MB compressed image and expand it to 932MB...
|
||||
# This test download a 196MB compressed image and expand it to 1GB
|
||||
image_url = ('https://dl.armbian.com/orangepipc/archive/'
|
||||
'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.7z')
|
||||
image_hash = '196a8ffb72b0123d92cea4a070894813d305c71e'
|
||||
@@ -642,6 +662,7 @@ class BootLinuxConsole(Test):
|
||||
image_name = 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.img'
|
||||
image_path = os.path.join(self.workdir, image_name)
|
||||
process.run("7z e -o%s %s" % (self.workdir, image_path_7z))
|
||||
image_pow2ceil_expand(image_path)
|
||||
|
||||
self.vm.set_console()
|
||||
self.vm.add_args('-drive', 'file=' + image_path + ',if=sd,format=raw',
|
||||
@@ -673,8 +694,9 @@ class BootLinuxConsole(Test):
|
||||
"""
|
||||
:avocado: tags=arch:arm
|
||||
:avocado: tags=machine:orangepi-pc
|
||||
:avocado: tags=device:sd
|
||||
"""
|
||||
# This test download a 304MB compressed image and expand it to 1.3GB...
|
||||
# This test download a 304MB compressed image and expand it to 2GB
|
||||
deb_url = ('http://snapshot.debian.org/archive/debian/'
|
||||
'20200108T145233Z/pool/main/u/u-boot/'
|
||||
'u-boot-sunxi_2020.01%2Bdfsg-1_armhf.deb')
|
||||
@@ -691,8 +713,9 @@ class BootLinuxConsole(Test):
|
||||
image_hash = '2babb29d36d8360adcb39c09e31060945259917a'
|
||||
image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash)
|
||||
image_path = os.path.join(self.workdir, 'armv7.img')
|
||||
image_drive_args = 'if=sd,format=raw,snapshot=on,file=' + image_path
|
||||
archive.gzip_uncompress(image_path_gz, image_path)
|
||||
image_pow2ceil_expand(image_path)
|
||||
image_drive_args = 'if=sd,format=raw,snapshot=on,file=' + image_path
|
||||
|
||||
# dd if=u-boot-sunxi-with-spl.bin of=armv7.img bs=1K seek=8 conv=notrunc
|
||||
with open(uboot_path, 'rb') as f_in:
|
||||
@@ -700,12 +723,6 @@ class BootLinuxConsole(Test):
|
||||
f_out.seek(8 * 1024)
|
||||
shutil.copyfileobj(f_in, f_out)
|
||||
|
||||
# Extend image, to avoid that NetBSD thinks the partition
|
||||
# inside the image is larger than device size itself
|
||||
f_out.seek(0, 2)
|
||||
f_out.seek(64 * 1024 * 1024, 1)
|
||||
f_out.write(bytearray([0x00]))
|
||||
|
||||
self.vm.set_console()
|
||||
self.vm.add_args('-nic', 'user',
|
||||
'-drive', image_drive_args,
|
||||
|
||||
@@ -142,6 +142,25 @@ TEST_IMG="${TEST_IMG}.copy" io_zero readv $(( offset + 32 * 1024 )) 512 1024 32
|
||||
|
||||
_check_test_img
|
||||
|
||||
echo
|
||||
echo '=== Reading across backing EOF in one operation ==='
|
||||
echo
|
||||
|
||||
# Use a cluster boundary as the base end here
|
||||
base_size=$((3 * 1024 * 1024 * 1024))
|
||||
|
||||
TEST_IMG="$TEST_IMG.base" _make_test_img $base_size
|
||||
_make_test_img -b "$TEST_IMG.base" -F $IMGFMT $image_size
|
||||
|
||||
# Write 16 times 42 at the end of the base image
|
||||
$QEMU_IO -c "write -P 42 $((base_size - 16)) 16" "$TEST_IMG.base" \
|
||||
| _filter_qemu_io
|
||||
|
||||
# Read 32 bytes across the base EOF from the top;
|
||||
# should be 16 times 0x2a, then 16 times 0x00
|
||||
$QEMU_IO -c "read -v $((base_size - 16)) 32" "$TEST_IMG" \
|
||||
| _filter_qemu_io
|
||||
|
||||
# success, all done
|
||||
echo "*** done"
|
||||
rm -f $seq.full
|
||||
|
||||
@@ -730,4 +730,15 @@ read 512/512 bytes at offset 3221257728
|
||||
read 512/512 bytes at offset 3221258752
|
||||
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
No errors were found on the image.
|
||||
|
||||
=== Reading across backing EOF in one operation ===
|
||||
|
||||
Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=3221225472
|
||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4294968832 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=IMGFMT
|
||||
wrote 16/16 bytes at offset 3221225456
|
||||
16 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
bffffff0: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ................
|
||||
c0000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
|
||||
read 32/32 bytes at offset 3221225456
|
||||
32 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
*** done
|
||||
@@ -58,6 +58,10 @@ _send_qemu_cmd $QEMU_HANDLE \
|
||||
$QEMU_IO_PROG -f raw -c quit \
|
||||
"nbd+unix:///no_such_export?socket=$SOCK_DIR/nbd" 2>&1 \
|
||||
| _filter_qemu_io | _filter_nbd
|
||||
# Likewise, with longest possible name permitted in NBD protocol
|
||||
$QEMU_IO_PROG -f raw -c quit \
|
||||
"nbd+unix:///$(printf %4096d 1 | tr ' ' a)?socket=$SOCK_DIR/nbd" 2>&1 \
|
||||
| _filter_qemu_io | _filter_nbd | sed 's/aaaa*aa/aa--aa/'
|
||||
|
||||
_send_qemu_cmd $QEMU_HANDLE \
|
||||
"{ 'execute': 'quit' }" \
|
||||
|
||||
@@ -5,6 +5,8 @@ QA output created by 143
|
||||
{"return": {}}
|
||||
qemu-io: can't open device nbd+unix:///no_such_export?socket=SOCK_DIR/nbd: Requested export not available
|
||||
server reported: export 'no_such_export' not present
|
||||
qemu-io: can't open device nbd+unix:///aa--aa1?socket=SOCK_DIR/nbd: Requested export not available
|
||||
server reported: export 'aa--aa...' not present
|
||||
{ 'execute': 'quit' }
|
||||
{"return": {}}
|
||||
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}}
|
||||
|
||||
@@ -72,7 +72,11 @@ to check that crash is fixed :)
|
||||
vm = iotests.VM()
|
||||
vm.launch()
|
||||
|
||||
vm.qmp_log('blockdev-add', **{'node-name': 'target', 'driver': 'null-co'})
|
||||
vm.qmp_log('blockdev-add', **{
|
||||
'node-name': 'target',
|
||||
'driver': 'null-co',
|
||||
'size': size,
|
||||
})
|
||||
|
||||
vm.qmp_log('blockdev-add', **{
|
||||
'node-name': 'source',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "target"}}
|
||||
{"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "target", "size": 1048576}}
|
||||
{"return": {}}
|
||||
{"execute": "blockdev-add", "arguments": {"driver": "blkdebug", "image": {"driver": "null-co", "node-name": "base", "size": 1048576}, "node-name": "source"}}
|
||||
{"return": {}}
|
||||
|
||||
@@ -186,7 +186,7 @@ void qpci_unplug_acpi_device_test(QTestState *qts, const char *id, uint8_t slot)
|
||||
g_assert(!qdict_haskey(response, "error"));
|
||||
qobject_unref(response);
|
||||
|
||||
qtest_outb(qts, ACPI_PCIHP_ADDR + PCI_EJ_BASE, 1 << slot);
|
||||
qtest_outl(qts, ACPI_PCIHP_ADDR + PCI_EJ_BASE, 1 << slot);
|
||||
|
||||
qtest_qmp_eventwait(qts, "DEVICE_DELETED");
|
||||
}
|
||||
|
||||
@@ -139,7 +139,11 @@ void tpm_util_pcrread(QTestState *s, tx_func *tx,
|
||||
|
||||
tx(s, tpm_pcrread, sizeof(tpm_pcrread), buffer, sizeof(buffer));
|
||||
|
||||
g_assert_cmpmem(buffer, exp_resp_size, exp_resp, exp_resp_size);
|
||||
/* skip pcrUpdateCounter (14th byte) in comparison */
|
||||
g_assert(exp_resp_size >= 15);
|
||||
g_assert_cmpmem(buffer, 13, exp_resp, 13);
|
||||
g_assert_cmpmem(&buffer[14], exp_resp_size - 14,
|
||||
&exp_resp[14], exp_resp_size - 14);
|
||||
}
|
||||
|
||||
bool tpm_util_swtpm_has_tpm2(void)
|
||||
|
||||
@@ -96,7 +96,7 @@ static void pci_ehci_port_1(void)
|
||||
static void pci_ehci_config(void)
|
||||
{
|
||||
/* hands over all ports from companion uhci to ehci */
|
||||
qpci_io_writew(ehci1.dev, ehci1.bar, 0x60, 1);
|
||||
qpci_io_writel(ehci1.dev, ehci1.bar, 0x60, 1);
|
||||
}
|
||||
|
||||
static void pci_uhci_port_2(void)
|
||||
|
||||
@@ -1777,6 +1777,7 @@ struct fuse_cmdline_opts {
|
||||
int syslog;
|
||||
int log_level;
|
||||
unsigned int max_idle_threads;
|
||||
unsigned long rlimit_nofile;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define FUSE_HELPER_OPT(t, p) \
|
||||
@@ -53,6 +55,7 @@ static const struct fuse_opt fuse_helper_opts[] = {
|
||||
FUSE_HELPER_OPT("subtype=", nodefault_subtype),
|
||||
FUSE_OPT_KEY("subtype=", FUSE_OPT_KEY_KEEP),
|
||||
FUSE_HELPER_OPT("max_idle_threads=%u", max_idle_threads),
|
||||
FUSE_HELPER_OPT("--rlimit-nofile=%lu", rlimit_nofile),
|
||||
FUSE_HELPER_OPT("--syslog", syslog),
|
||||
FUSE_HELPER_OPT_VALUE("log_level=debug", log_level, FUSE_LOG_DEBUG),
|
||||
FUSE_HELPER_OPT_VALUE("log_level=info", log_level, FUSE_LOG_INFO),
|
||||
@@ -171,6 +174,10 @@ void fuse_cmdline_help(void)
|
||||
" default: no_writeback\n"
|
||||
" -o xattr|no_xattr enable/disable xattr\n"
|
||||
" default: no_xattr\n"
|
||||
" --rlimit-nofile=<num> set maximum number of file descriptors\n"
|
||||
" (0 leaves rlimit unchanged)\n"
|
||||
" default: min(1000000, fs.file-max - 16384)\n"
|
||||
" if the current rlimit is lower\n"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -191,11 +198,51 @@ static int fuse_helper_opt_proc(void *data, const char *arg, int key,
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned long get_default_rlimit_nofile(void)
|
||||
{
|
||||
g_autofree gchar *file_max_str = NULL;
|
||||
const rlim_t reserved_fds = 16384; /* leave at least this many fds free */
|
||||
rlim_t max_fds = 1000000; /* our default RLIMIT_NOFILE target */
|
||||
rlim_t file_max;
|
||||
struct rlimit rlim;
|
||||
|
||||
/*
|
||||
* Reduce max_fds below the system-wide maximum, if necessary. This
|
||||
* ensures there are fds available for other processes so we don't
|
||||
* cause resource exhaustion.
|
||||
*/
|
||||
if (!g_file_get_contents("/proc/sys/fs/file-max", &file_max_str,
|
||||
NULL, NULL)) {
|
||||
fuse_log(FUSE_LOG_ERR, "can't read /proc/sys/fs/file-max\n");
|
||||
exit(1);
|
||||
}
|
||||
file_max = g_ascii_strtoull(file_max_str, NULL, 10);
|
||||
if (file_max < 2 * reserved_fds) {
|
||||
fuse_log(FUSE_LOG_ERR,
|
||||
"The fs.file-max sysctl is too low (%lu) to allow a "
|
||||
"reasonable number of open files.\n",
|
||||
(unsigned long)file_max);
|
||||
exit(1);
|
||||
}
|
||||
max_fds = MIN(file_max - reserved_fds, max_fds);
|
||||
|
||||
if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) {
|
||||
fuse_log(FUSE_LOG_ERR, "getrlimit(RLIMIT_NOFILE): %m\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (rlim.rlim_cur >= max_fds) {
|
||||
return 0; /* we have more fds available than required! */
|
||||
}
|
||||
return max_fds;
|
||||
}
|
||||
|
||||
int fuse_parse_cmdline(struct fuse_args *args, struct fuse_cmdline_opts *opts)
|
||||
{
|
||||
memset(opts, 0, sizeof(struct fuse_cmdline_opts));
|
||||
|
||||
opts->max_idle_threads = 10;
|
||||
opts->rlimit_nofile = get_default_rlimit_nofile();
|
||||
opts->foreground = 1;
|
||||
|
||||
if (fuse_opt_parse(args, opts, fuse_helper_opts, fuse_helper_opt_proc) ==
|
||||
|
||||
@@ -2707,24 +2707,18 @@ static void setup_sandbox(struct lo_data *lo, struct fuse_session *se,
|
||||
setup_seccomp(enable_syslog);
|
||||
}
|
||||
|
||||
/* Raise the maximum number of open file descriptors */
|
||||
static void setup_nofile_rlimit(void)
|
||||
/* Set the maximum number of open file descriptors */
|
||||
static void setup_nofile_rlimit(unsigned long rlimit_nofile)
|
||||
{
|
||||
const rlim_t max_fds = 1000000;
|
||||
struct rlimit rlim;
|
||||
struct rlimit rlim = {
|
||||
.rlim_cur = rlimit_nofile,
|
||||
.rlim_max = rlimit_nofile,
|
||||
};
|
||||
|
||||
if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) {
|
||||
fuse_log(FUSE_LOG_ERR, "getrlimit(RLIMIT_NOFILE): %m\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (rlim.rlim_cur >= max_fds) {
|
||||
if (rlimit_nofile == 0) {
|
||||
return; /* nothing to do */
|
||||
}
|
||||
|
||||
rlim.rlim_cur = max_fds;
|
||||
rlim.rlim_max = max_fds;
|
||||
|
||||
if (setrlimit(RLIMIT_NOFILE, &rlim) < 0) {
|
||||
/* Ignore SELinux denials */
|
||||
if (errno == EPERM) {
|
||||
@@ -2977,7 +2971,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
fuse_daemonize(opts.foreground);
|
||||
|
||||
setup_nofile_rlimit();
|
||||
setup_nofile_rlimit(opts.rlimit_nofile);
|
||||
|
||||
/* Must be before sandbox since it wants /proc */
|
||||
setup_capng();
|
||||
|
||||
@@ -42,6 +42,7 @@ static const int syscall_whitelist[] = {
|
||||
SCMP_SYS(exit_group),
|
||||
SCMP_SYS(fallocate),
|
||||
SCMP_SYS(fchdir),
|
||||
SCMP_SYS(fchmod),
|
||||
SCMP_SYS(fchmodat),
|
||||
SCMP_SYS(fchownat),
|
||||
SCMP_SYS(fcntl),
|
||||
|
||||
@@ -679,6 +679,19 @@ void aio_context_destroy(AioContext *ctx)
|
||||
{
|
||||
fdmon_io_uring_destroy(ctx);
|
||||
fdmon_epoll_disable(ctx);
|
||||
aio_free_deleted_handlers(ctx);
|
||||
}
|
||||
|
||||
void aio_context_use_g_source(AioContext *ctx)
|
||||
{
|
||||
/*
|
||||
* Disable io_uring when the glib main loop is used because it doesn't
|
||||
* support mixed glib/aio_poll() usage. It relies on aio_poll() being
|
||||
* called regularly so that changes to the monitored file descriptors are
|
||||
* submitted, otherwise a list of pending fd handlers builds up.
|
||||
*/
|
||||
fdmon_io_uring_destroy(ctx);
|
||||
aio_free_deleted_handlers(ctx);
|
||||
}
|
||||
|
||||
void aio_context_set_poll_params(AioContext *ctx, int64_t max_ns,
|
||||
|
||||
@@ -414,6 +414,10 @@ void aio_context_destroy(AioContext *ctx)
|
||||
{
|
||||
}
|
||||
|
||||
void aio_context_use_g_source(AioContext *ctx)
|
||||
{
|
||||
}
|
||||
|
||||
void aio_context_set_poll_params(AioContext *ctx, int64_t max_ns,
|
||||
int64_t grow, int64_t shrink, Error **errp)
|
||||
{
|
||||
|
||||
Loaded 100 of 104 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user