mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
* xsetbv fix (x86 targets TCG) * remove unused functions * qht segfault and memory leak fixes * NBD fixes * Fix for non-power-of-2 discard granularity * Memory hotplug fixes * Migration regressions * IOAPIC fixes and (disabled by default) EOI register support * Various other small fixes # gpg: Signature made Wed 03 Aug 2016 18:01:05 BST # gpg: using RSA key 0xBFFBD25F78C7AE83 # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * remotes/bonzini/tags/for-upstream: (25 commits) util: Fix assertion in iov_copy() upon zero 'bytes' and non-zero 'offset' qdev: Fix use after free in qdev_init_nofail error path Reorganize help output of '-display' option x86: ioapic: add support for explicit EOI x86: ioapic: ignore level irq during processing apic: fix broken migration for kvm-apic fw_cfg: Make base type "fw_cfg" abstract block: Cater to iscsi with non-power-of-2 discard osdep: Document differences in rounding macros nbd: Limit nbdflags to 16 bits nbd: Fix bad flag detection on server i2c: fix migration regression introduced by broadcast support mptsas: really fix migration compatibility qdist: return "(empty)" instead of NULL when printing an empty dist qdist: use g_renew and g_new instead of g_realloc and g_malloc. qdist: fix memory leak during binning target-i386: fix typo in xsetbv implementation qht: do not segfault when gathering stats from an uninitialized qht util: Drop inet_listen() util: drop unix_nonblocking_connect() ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
+14
-4
@@ -203,6 +203,7 @@ static bool host_memory_backend_get_prealloc(Object *obj, Error **errp)
|
||||
static void host_memory_backend_set_prealloc(Object *obj, bool value,
|
||||
Error **errp)
|
||||
{
|
||||
Error *local_err = NULL;
|
||||
HostMemoryBackend *backend = MEMORY_BACKEND(obj);
|
||||
|
||||
if (backend->force_prealloc) {
|
||||
@@ -223,7 +224,11 @@ static void host_memory_backend_set_prealloc(Object *obj, bool value,
|
||||
void *ptr = memory_region_get_ram_ptr(&backend->mr);
|
||||
uint64_t sz = memory_region_size(&backend->mr);
|
||||
|
||||
os_mem_prealloc(fd, ptr, sz);
|
||||
os_mem_prealloc(fd, ptr, sz, &local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
return;
|
||||
}
|
||||
backend->prealloc = true;
|
||||
}
|
||||
}
|
||||
@@ -286,8 +291,7 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
|
||||
if (bc->alloc) {
|
||||
bc->alloc(backend, &local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
return;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ptr = memory_region_get_ram_ptr(&backend->mr);
|
||||
@@ -343,9 +347,15 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
|
||||
* specified NUMA policy in place.
|
||||
*/
|
||||
if (backend->prealloc) {
|
||||
os_mem_prealloc(memory_region_get_fd(&backend->mr), ptr, sz);
|
||||
os_mem_prealloc(memory_region_get_fd(&backend->mr), ptr, sz,
|
||||
&local_err);
|
||||
if (local_err) {
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
out:
|
||||
error_propagate(errp, local_err);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
||||
+9
-6
@@ -1180,10 +1180,11 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
|
||||
int alignment = MAX(bs->bl.pwrite_zeroes_alignment,
|
||||
bs->bl.request_alignment);
|
||||
|
||||
assert(is_power_of_2(alignment));
|
||||
head = offset & (alignment - 1);
|
||||
tail = (offset + count) & (alignment - 1);
|
||||
max_write_zeroes &= ~(alignment - 1);
|
||||
assert(alignment % bs->bl.request_alignment == 0);
|
||||
head = offset % alignment;
|
||||
tail = (offset + count) % alignment;
|
||||
max_write_zeroes = QEMU_ALIGN_DOWN(max_write_zeroes, alignment);
|
||||
assert(max_write_zeroes >= bs->bl.request_alignment);
|
||||
|
||||
while (count > 0 && !ret) {
|
||||
int num = count;
|
||||
@@ -2429,9 +2430,10 @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset,
|
||||
|
||||
/* Discard is advisory, so ignore any unaligned head or tail */
|
||||
align = MAX(bs->bl.pdiscard_alignment, bs->bl.request_alignment);
|
||||
assert(is_power_of_2(align));
|
||||
head = MIN(count, -offset & (align - 1));
|
||||
assert(align % bs->bl.request_alignment == 0);
|
||||
head = offset % align;
|
||||
if (head) {
|
||||
head = MIN(count, align - head);
|
||||
count -= head;
|
||||
offset += head;
|
||||
}
|
||||
@@ -2449,6 +2451,7 @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset,
|
||||
|
||||
max_pdiscard = QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_pdiscard, INT_MAX),
|
||||
align);
|
||||
assert(max_pdiscard);
|
||||
|
||||
while (count > 0) {
|
||||
int ret;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
typedef struct NbdClientSession {
|
||||
QIOChannelSocket *sioc; /* The master data channel */
|
||||
QIOChannel *ioc; /* The current I/O channel which may differ (eg TLS) */
|
||||
uint32_t nbdflags;
|
||||
uint16_t nbdflags;
|
||||
off_t size;
|
||||
|
||||
CoMutex send_mutex;
|
||||
|
||||
@@ -1226,7 +1226,7 @@ static void *file_ram_alloc(RAMBlock *block,
|
||||
char *filename;
|
||||
char *sanitized_name;
|
||||
char *c;
|
||||
void *area;
|
||||
void *area = MAP_FAILED;
|
||||
int fd = -1;
|
||||
int64_t page_size;
|
||||
|
||||
@@ -1314,13 +1314,19 @@ static void *file_ram_alloc(RAMBlock *block,
|
||||
}
|
||||
|
||||
if (mem_prealloc) {
|
||||
os_mem_prealloc(fd, area, memory);
|
||||
os_mem_prealloc(fd, area, memory, errp);
|
||||
if (errp && *errp) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
block->fd = fd;
|
||||
return area;
|
||||
|
||||
error:
|
||||
if (area != MAP_FAILED) {
|
||||
qemu_ram_munmap(area, memory);
|
||||
}
|
||||
if (unlink_on_error) {
|
||||
unlink(path);
|
||||
}
|
||||
|
||||
@@ -354,12 +354,14 @@ void qdev_init_nofail(DeviceState *dev)
|
||||
|
||||
assert(!dev->realized);
|
||||
|
||||
object_ref(OBJECT(dev));
|
||||
object_property_set_bool(OBJECT(dev), true, "realized", &err);
|
||||
if (err) {
|
||||
error_reportf_err(err, "Initialization of device %s failed: ",
|
||||
object_get_typename(OBJECT(dev)));
|
||||
exit(1);
|
||||
}
|
||||
object_unref(OBJECT(dev));
|
||||
}
|
||||
|
||||
void qdev_machine_creation_done(void)
|
||||
|
||||
+7
-3
@@ -17,6 +17,8 @@ struct I2CNode {
|
||||
QLIST_ENTRY(I2CNode) next;
|
||||
};
|
||||
|
||||
#define I2C_BROADCAST 0x00
|
||||
|
||||
struct I2CBus
|
||||
{
|
||||
BusState qbus;
|
||||
@@ -47,6 +49,8 @@ static void i2c_bus_pre_save(void *opaque)
|
||||
if (!QLIST_EMPTY(&bus->current_devs)) {
|
||||
if (!bus->broadcast) {
|
||||
bus->saved_address = QLIST_FIRST(&bus->current_devs)->elt->address;
|
||||
} else {
|
||||
bus->saved_address = I2C_BROADCAST;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,7 +62,6 @@ static const VMStateDescription vmstate_i2c_bus = {
|
||||
.pre_save = i2c_bus_pre_save,
|
||||
.fields = (VMStateField[]) {
|
||||
VMSTATE_UINT8(saved_address, I2CBus),
|
||||
VMSTATE_BOOL(broadcast, I2CBus),
|
||||
VMSTATE_END_OF_LIST()
|
||||
}
|
||||
};
|
||||
@@ -93,7 +96,7 @@ int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv)
|
||||
I2CSlaveClass *sc;
|
||||
I2CNode *node;
|
||||
|
||||
if (address == 0x00) {
|
||||
if (address == I2C_BROADCAST) {
|
||||
/*
|
||||
* This is a broadcast, the current_devs will be all the devices of the
|
||||
* bus.
|
||||
@@ -221,7 +224,8 @@ static int i2c_slave_post_load(void *opaque, int version_id)
|
||||
I2CNode *node;
|
||||
|
||||
bus = I2C_BUS(qdev_get_parent_bus(DEVICE(dev)));
|
||||
if ((bus->saved_address == dev->address) || (bus->broadcast)) {
|
||||
if ((bus->saved_address == dev->address) ||
|
||||
(bus->saved_address == I2C_BROADCAST)) {
|
||||
node = g_malloc(sizeof(struct I2CNode));
|
||||
node->elt = dev;
|
||||
QLIST_INSERT_HEAD(&bus->current_devs, node, next);
|
||||
|
||||
+30
-6
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "monitor/monitor.h"
|
||||
#include "hw/hw.h"
|
||||
#include "hw/i386/pc.h"
|
||||
@@ -117,21 +118,25 @@ static void ioapic_service(IOAPICCommonState *s)
|
||||
s->ioredtbl[i] |= IOAPIC_LVT_REMOTE_IRR;
|
||||
}
|
||||
|
||||
if (coalesce) {
|
||||
/* We are level triggered interrupts, and the
|
||||
* guest should be still working on previous one,
|
||||
* so skip it. */
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_KVM
|
||||
if (kvm_irqchip_is_split()) {
|
||||
if (info.trig_mode == IOAPIC_TRIGGER_EDGE) {
|
||||
kvm_set_irq(kvm_state, i, 1);
|
||||
kvm_set_irq(kvm_state, i, 0);
|
||||
} else {
|
||||
if (!coalesce) {
|
||||
kvm_set_irq(kvm_state, i, 1);
|
||||
}
|
||||
kvm_set_irq(kvm_state, i, 1);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
#else
|
||||
(void)coalesce;
|
||||
#endif
|
||||
|
||||
/* No matter whether IR is enabled, we translate
|
||||
* the IOAPIC message into a MSI one, and its
|
||||
* address space will decide whether we need a
|
||||
@@ -265,7 +270,7 @@ ioapic_mem_read(void *opaque, hwaddr addr, unsigned int size)
|
||||
val = s->id << IOAPIC_ID_SHIFT;
|
||||
break;
|
||||
case IOAPIC_REG_VER:
|
||||
val = IOAPIC_VERSION |
|
||||
val = s->version |
|
||||
((IOAPIC_NUM_PINS - 1) << IOAPIC_VER_ENTRIES_SHIFT);
|
||||
break;
|
||||
default:
|
||||
@@ -354,6 +359,13 @@ ioapic_mem_write(void *opaque, hwaddr addr, uint64_t val,
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IOAPIC_EOI:
|
||||
/* Explicit EOI is only supported for IOAPIC version 0x20 */
|
||||
if (size != 4 || s->version != 0x20) {
|
||||
break;
|
||||
}
|
||||
ioapic_eoi_broadcast(val);
|
||||
break;
|
||||
}
|
||||
|
||||
ioapic_update_kvm_routes(s);
|
||||
@@ -387,6 +399,12 @@ static void ioapic_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
IOAPICCommonState *s = IOAPIC_COMMON(dev);
|
||||
|
||||
if (s->version != 0x11 && s->version != 0x20) {
|
||||
error_report("IOAPIC only supports version 0x11 or 0x20 "
|
||||
"(default: 0x11).");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
memory_region_init_io(&s->io_memory, OBJECT(s), &ioapic_io_ops, s,
|
||||
"ioapic", 0x1000);
|
||||
|
||||
@@ -397,6 +415,11 @@ static void ioapic_realize(DeviceState *dev, Error **errp)
|
||||
qemu_add_machine_init_done_notifier(&s->machine_done);
|
||||
}
|
||||
|
||||
static Property ioapic_properties[] = {
|
||||
DEFINE_PROP_UINT8("version", IOAPICCommonState, version, 0x11),
|
||||
DEFINE_PROP_END_OF_LIST(),
|
||||
};
|
||||
|
||||
static void ioapic_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
IOAPICCommonClass *k = IOAPIC_COMMON_CLASS(klass);
|
||||
@@ -404,6 +427,7 @@ static void ioapic_class_init(ObjectClass *klass, void *data)
|
||||
|
||||
k->realize = ioapic_realize;
|
||||
dc->reset = ioapic_reset_common;
|
||||
dc->props = ioapic_properties;
|
||||
}
|
||||
|
||||
static const TypeInfo ioapic_info = {
|
||||
|
||||
@@ -990,6 +990,7 @@ static void fw_cfg_class_init(ObjectClass *klass, void *data)
|
||||
static const TypeInfo fw_cfg_info = {
|
||||
.name = TYPE_FW_CFG,
|
||||
.parent = TYPE_SYS_BUS_DEVICE,
|
||||
.abstract = true,
|
||||
.instance_size = sizeof(FWCfgState),
|
||||
.class_init = fw_cfg_class_init,
|
||||
};
|
||||
|
||||
+3
-1
@@ -1295,6 +1295,8 @@ static void mptsas_scsi_init(PCIDevice *dev, Error **errp)
|
||||
/* With msi=auto, we fall back to MSI off silently */
|
||||
error_free(err);
|
||||
|
||||
/* Only used for migration. */
|
||||
s->msi_in_use = (ret == 0);
|
||||
}
|
||||
|
||||
memory_region_init_io(&s->mmio_io, OBJECT(s), &mptsas_mmio_ops, s,
|
||||
@@ -1370,7 +1372,7 @@ static const VMStateDescription vmstate_mptsas = {
|
||||
.post_load = mptsas_post_load,
|
||||
.fields = (VMStateField[]) {
|
||||
VMSTATE_PCI_DEVICE(dev, MPTSASState),
|
||||
VMSTATE_UNUSED(sizeof(bool)), /* Was msi_in_use */
|
||||
VMSTATE_BOOL(msi_in_use, MPTSASState),
|
||||
VMSTATE_UINT32(state, MPTSASState),
|
||||
VMSTATE_UINT8(who_init, MPTSASState),
|
||||
VMSTATE_UINT8(doorbell_state, MPTSASState),
|
||||
|
||||
@@ -31,6 +31,8 @@ struct MPTSASState {
|
||||
OnOffAuto msi;
|
||||
uint64_t sas_addr;
|
||||
|
||||
bool msi_in_use;
|
||||
|
||||
/* Doorbell register */
|
||||
uint32_t state;
|
||||
uint8_t who_init;
|
||||
|
||||
+20
-17
@@ -330,36 +330,39 @@ typedef struct BlockLimits {
|
||||
* otherwise. */
|
||||
uint32_t request_alignment;
|
||||
|
||||
/* maximum number of bytes that can be discarded at once (since it
|
||||
* is signed, it must be < 2G, if set), should be multiple of
|
||||
/* Maximum number of bytes that can be discarded at once (since it
|
||||
* is signed, it must be < 2G, if set). Must be multiple of
|
||||
* pdiscard_alignment, but need not be power of 2. May be 0 if no
|
||||
* inherent 32-bit limit */
|
||||
int32_t max_pdiscard;
|
||||
|
||||
/* optimal alignment for discard requests in bytes, must be power
|
||||
* of 2, less than max_pdiscard if that is set, and multiple of
|
||||
* bl.request_alignment. May be 0 if bl.request_alignment is good
|
||||
* enough */
|
||||
/* Optimal alignment for discard requests in bytes. A power of 2
|
||||
* is best but not mandatory. Must be a multiple of
|
||||
* bl.request_alignment, and must be less than max_pdiscard if
|
||||
* that is set. May be 0 if bl.request_alignment is good enough */
|
||||
uint32_t pdiscard_alignment;
|
||||
|
||||
/* maximum number of bytes that can zeroized at once (since it is
|
||||
* signed, it must be < 2G, if set), should be multiple of
|
||||
/* Maximum number of bytes that can zeroized at once (since it is
|
||||
* signed, it must be < 2G, if set). Must be multiple of
|
||||
* pwrite_zeroes_alignment. May be 0 if no inherent 32-bit limit */
|
||||
int32_t max_pwrite_zeroes;
|
||||
|
||||
/* optimal alignment for write zeroes requests in bytes, must be
|
||||
* power of 2, less than max_pwrite_zeroes if that is set, and
|
||||
* multiple of bl.request_alignment. May be 0 if
|
||||
* bl.request_alignment is good enough */
|
||||
/* Optimal alignment for write zeroes requests in bytes. A power
|
||||
* of 2 is best but not mandatory. Must be a multiple of
|
||||
* bl.request_alignment, and must be less than max_pwrite_zeroes
|
||||
* if that is set. May be 0 if bl.request_alignment is good
|
||||
* enough */
|
||||
uint32_t pwrite_zeroes_alignment;
|
||||
|
||||
/* optimal transfer length in bytes (must be power of 2, and
|
||||
* multiple of bl.request_alignment), or 0 if no preferred size */
|
||||
/* Optimal transfer length in bytes. A power of 2 is best but not
|
||||
* mandatory. Must be a multiple of bl.request_alignment, or 0 if
|
||||
* no preferred size */
|
||||
uint32_t opt_transfer;
|
||||
|
||||
/* maximal transfer length in bytes (need not be power of 2, but
|
||||
* should be multiple of opt_transfer), or 0 for no 32-bit limit.
|
||||
* For now, anything larger than INT_MAX is clamped down. */
|
||||
/* Maximal transfer length in bytes. Need not be power of 2, but
|
||||
* must be multiple of opt_transfer and bl.request_alignment, or 0
|
||||
* for no 32-bit limit. For now, anything larger than INT_MAX is
|
||||
* clamped down. */
|
||||
uint32_t max_transfer;
|
||||
|
||||
/* memory alignment, in bytes so that no bounce buffer is needed */
|
||||
|
||||
+3
-3
@@ -90,11 +90,11 @@ ssize_t nbd_wr_syncv(QIOChannel *ioc,
|
||||
size_t niov,
|
||||
size_t length,
|
||||
bool do_read);
|
||||
int nbd_receive_negotiate(QIOChannel *ioc, const char *name, uint32_t *flags,
|
||||
int nbd_receive_negotiate(QIOChannel *ioc, const char *name, uint16_t *flags,
|
||||
QCryptoTLSCreds *tlscreds, const char *hostname,
|
||||
QIOChannel **outioc,
|
||||
off_t *size, Error **errp);
|
||||
int nbd_init(int fd, QIOChannelSocket *sioc, uint32_t flags, off_t size);
|
||||
int nbd_init(int fd, QIOChannelSocket *sioc, uint16_t flags, off_t size);
|
||||
ssize_t nbd_send_request(QIOChannel *ioc, struct nbd_request *request);
|
||||
ssize_t nbd_receive_reply(QIOChannel *ioc, struct nbd_reply *reply);
|
||||
int nbd_client(int fd);
|
||||
@@ -104,7 +104,7 @@ typedef struct NBDExport NBDExport;
|
||||
typedef struct NBDClient NBDClient;
|
||||
|
||||
NBDExport *nbd_export_new(BlockBackend *blk, off_t dev_offset, off_t size,
|
||||
uint32_t nbdflags, void (*close)(NBDExport *),
|
||||
uint16_t nbdflags, void (*close)(NBDExport *),
|
||||
Error **errp);
|
||||
void nbd_export_close(NBDExport *exp);
|
||||
void nbd_export_get(NBDExport *exp);
|
||||
|
||||
@@ -29,8 +29,6 @@
|
||||
|
||||
#define MAX_IOAPICS 1
|
||||
|
||||
#define IOAPIC_VERSION 0x11
|
||||
|
||||
#define IOAPIC_LVT_DEST_SHIFT 56
|
||||
#define IOAPIC_LVT_DEST_IDX_SHIFT 48
|
||||
#define IOAPIC_LVT_MASKED_SHIFT 16
|
||||
@@ -71,6 +69,7 @@
|
||||
|
||||
#define IOAPIC_IOREGSEL 0x00
|
||||
#define IOAPIC_IOWIN 0x10
|
||||
#define IOAPIC_EOI 0x40
|
||||
|
||||
#define IOAPIC_REG_ID 0x00
|
||||
#define IOAPIC_REG_VER 0x01
|
||||
@@ -109,6 +108,7 @@ struct IOAPICCommonState {
|
||||
uint32_t irr;
|
||||
uint64_t ioredtbl[IOAPIC_NUM_PINS];
|
||||
Notifier machine_done;
|
||||
uint8_t version;
|
||||
};
|
||||
|
||||
void ioapic_reset_common(DeviceState *dev);
|
||||
|
||||
@@ -388,7 +388,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
|
||||
.value = "off",\
|
||||
},\
|
||||
{\
|
||||
.driver = "apic",\
|
||||
.driver = "apic-common",\
|
||||
.property = "legacy-instance-id",\
|
||||
.value = "on",\
|
||||
},
|
||||
|
||||
@@ -158,7 +158,8 @@ extern int daemon(int, int);
|
||||
/* Round number down to multiple */
|
||||
#define QEMU_ALIGN_DOWN(n, m) ((n) / (m) * (m))
|
||||
|
||||
/* Round number up to multiple */
|
||||
/* Round number up to multiple. Safe when m is not a power of 2 (see
|
||||
* ROUND_UP for a faster version when a power of 2 is guaranteed) */
|
||||
#define QEMU_ALIGN_UP(n, m) QEMU_ALIGN_DOWN((n) + (m) - 1, (m))
|
||||
|
||||
/* Check if n is a multiple of m */
|
||||
@@ -175,6 +176,9 @@ extern int daemon(int, int);
|
||||
/* Check if pointer p is n-bytes aligned */
|
||||
#define QEMU_PTR_IS_ALIGNED(p, n) QEMU_IS_ALIGNED((uintptr_t)(p), (n))
|
||||
|
||||
/* Round number up to multiple. Requires that d be a power of 2 (see
|
||||
* QEMU_ALIGN_UP for a safer but slower version on arbitrary
|
||||
* numbers) */
|
||||
#ifndef ROUND_UP
|
||||
#define ROUND_UP(n,d) (((n) + (d) - 1) & -(d))
|
||||
#endif
|
||||
@@ -379,7 +383,7 @@ unsigned long qemu_getauxval(unsigned long type);
|
||||
|
||||
void qemu_set_tty_echo(int fd, bool echo);
|
||||
|
||||
void os_mem_prealloc(int fd, char *area, size_t sz);
|
||||
void os_mem_prealloc(int fd, char *area, size_t sz, Error **errp);
|
||||
|
||||
int qemu_read_password(char *buf, int buf_size);
|
||||
|
||||
|
||||
@@ -69,6 +69,9 @@ void qht_destroy(struct qht *ht);
|
||||
* Attempting to insert a NULL @p is a bug.
|
||||
* Inserting the same pointer @p with different @hash values is a bug.
|
||||
*
|
||||
* In case of successful operation, smp_wmb() is implied before the pointer is
|
||||
* inserted into the hash table.
|
||||
*
|
||||
* Returns true on sucess.
|
||||
* Returns false if the @p-@hash pair already exists in the hash table.
|
||||
*/
|
||||
@@ -83,6 +86,8 @@ bool qht_insert(struct qht *ht, void *p, uint32_t hash);
|
||||
*
|
||||
* Needs to be called under an RCU read-critical section.
|
||||
*
|
||||
* smp_read_barrier_depends() is implied before the call to @func.
|
||||
*
|
||||
* The user-provided @func compares pointers in QHT against @userp.
|
||||
* If the function returns true, a match has been found.
|
||||
*
|
||||
|
||||
@@ -33,20 +33,12 @@ int socket_set_fast_reuse(int fd);
|
||||
typedef void NonBlockingConnectHandler(int fd, Error *err, void *opaque);
|
||||
|
||||
InetSocketAddress *inet_parse(const char *str, Error **errp);
|
||||
int inet_listen(const char *str, char *ostr, int olen,
|
||||
int socktype, int port_offset, Error **errp);
|
||||
int inet_connect(const char *str, Error **errp);
|
||||
int inet_nonblocking_connect(const char *str,
|
||||
NonBlockingConnectHandler *callback,
|
||||
void *opaque, Error **errp);
|
||||
|
||||
NetworkAddressFamily inet_netfamily(int family);
|
||||
|
||||
int unix_listen(const char *path, char *ostr, int olen, Error **errp);
|
||||
int unix_connect(const char *path, Error **errp);
|
||||
int unix_nonblocking_connect(const char *str,
|
||||
NonBlockingConnectHandler *callback,
|
||||
void *opaque, Error **errp);
|
||||
|
||||
SocketAddress *socket_parse(const char *str, Error **errp);
|
||||
int socket_connect(SocketAddress *addr, Error **errp,
|
||||
|
||||
+15
-13
@@ -408,7 +408,7 @@ static QIOChannel *nbd_receive_starttls(QIOChannel *ioc,
|
||||
}
|
||||
|
||||
|
||||
int nbd_receive_negotiate(QIOChannel *ioc, const char *name, uint32_t *flags,
|
||||
int nbd_receive_negotiate(QIOChannel *ioc, const char *name, uint16_t *flags,
|
||||
QCryptoTLSCreds *tlscreds, const char *hostname,
|
||||
QIOChannel **outioc,
|
||||
off_t *size, Error **errp)
|
||||
@@ -468,7 +468,6 @@ int nbd_receive_negotiate(QIOChannel *ioc, const char *name, uint32_t *flags,
|
||||
uint32_t opt;
|
||||
uint32_t namesize;
|
||||
uint16_t globalflags;
|
||||
uint16_t exportflags;
|
||||
bool fixedNewStyle = false;
|
||||
|
||||
if (read_sync(ioc, &globalflags, sizeof(globalflags)) !=
|
||||
@@ -477,7 +476,6 @@ int nbd_receive_negotiate(QIOChannel *ioc, const char *name, uint32_t *flags,
|
||||
goto fail;
|
||||
}
|
||||
globalflags = be16_to_cpu(globalflags);
|
||||
*flags = globalflags << 16;
|
||||
TRACE("Global flags are %" PRIx32, globalflags);
|
||||
if (globalflags & NBD_FLAG_FIXED_NEWSTYLE) {
|
||||
fixedNewStyle = true;
|
||||
@@ -545,17 +543,15 @@ int nbd_receive_negotiate(QIOChannel *ioc, const char *name, uint32_t *flags,
|
||||
goto fail;
|
||||
}
|
||||
*size = be64_to_cpu(s);
|
||||
TRACE("Size is %" PRIu64, *size);
|
||||
|
||||
if (read_sync(ioc, &exportflags, sizeof(exportflags)) !=
|
||||
sizeof(exportflags)) {
|
||||
if (read_sync(ioc, flags, sizeof(*flags)) != sizeof(*flags)) {
|
||||
error_setg(errp, "Failed to read export flags");
|
||||
goto fail;
|
||||
}
|
||||
exportflags = be16_to_cpu(exportflags);
|
||||
*flags |= exportflags;
|
||||
TRACE("Export flags are %" PRIx16, exportflags);
|
||||
be16_to_cpus(flags);
|
||||
} else if (magic == NBD_CLIENT_MAGIC) {
|
||||
uint32_t oldflags;
|
||||
|
||||
if (name) {
|
||||
error_setg(errp, "Server does not support export names");
|
||||
goto fail;
|
||||
@@ -572,16 +568,22 @@ int nbd_receive_negotiate(QIOChannel *ioc, const char *name, uint32_t *flags,
|
||||
*size = be64_to_cpu(s);
|
||||
TRACE("Size is %" PRIu64, *size);
|
||||
|
||||
if (read_sync(ioc, flags, sizeof(*flags)) != sizeof(*flags)) {
|
||||
if (read_sync(ioc, &oldflags, sizeof(oldflags)) != sizeof(oldflags)) {
|
||||
error_setg(errp, "Failed to read export flags");
|
||||
goto fail;
|
||||
}
|
||||
*flags = be32_to_cpu(*flags);
|
||||
be32_to_cpus(&oldflags);
|
||||
if (oldflags & ~0xffff) {
|
||||
error_setg(errp, "Unexpected export flags %0x" PRIx32, oldflags);
|
||||
goto fail;
|
||||
}
|
||||
*flags = oldflags;
|
||||
} else {
|
||||
error_setg(errp, "Bad magic received");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
TRACE("Size is %" PRIu64 ", export flags %" PRIx16, *size, *flags);
|
||||
if (read_sync(ioc, &buf, 124) != 124) {
|
||||
error_setg(errp, "Failed to read reserved block");
|
||||
goto fail;
|
||||
@@ -593,7 +595,7 @@ fail:
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
int nbd_init(int fd, QIOChannelSocket *sioc, uint32_t flags, off_t size)
|
||||
int nbd_init(int fd, QIOChannelSocket *sioc, uint16_t flags, off_t size)
|
||||
{
|
||||
unsigned long sectors = size / BDRV_SECTOR_SIZE;
|
||||
if (size / BDRV_SECTOR_SIZE != sectors) {
|
||||
@@ -689,7 +691,7 @@ int nbd_disconnect(int fd)
|
||||
}
|
||||
|
||||
#else
|
||||
int nbd_init(int fd, QIOChannelSocket *ioc, uint32_t flags, off_t size)
|
||||
int nbd_init(int fd, QIOChannelSocket *ioc, uint16_t flags, off_t size)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
+6
-7
@@ -63,7 +63,7 @@ struct NBDExport {
|
||||
char *name;
|
||||
off_t dev_offset;
|
||||
off_t size;
|
||||
uint32_t nbdflags;
|
||||
uint16_t nbdflags;
|
||||
QTAILQ_HEAD(, NBDClient) clients;
|
||||
QTAILQ_ENTRY(NBDExport) next;
|
||||
|
||||
@@ -544,8 +544,8 @@ static coroutine_fn int nbd_negotiate(NBDClientNewData *data)
|
||||
NBDClient *client = data->client;
|
||||
char buf[8 + 8 + 8 + 128];
|
||||
int rc;
|
||||
const int myflags = (NBD_FLAG_HAS_FLAGS | NBD_FLAG_SEND_TRIM |
|
||||
NBD_FLAG_SEND_FLUSH | NBD_FLAG_SEND_FUA);
|
||||
const uint16_t myflags = (NBD_FLAG_HAS_FLAGS | NBD_FLAG_SEND_TRIM |
|
||||
NBD_FLAG_SEND_FLUSH | NBD_FLAG_SEND_FUA);
|
||||
bool oldStyle;
|
||||
|
||||
/* Old style negotiation header without options
|
||||
@@ -575,7 +575,6 @@ static coroutine_fn int nbd_negotiate(NBDClientNewData *data)
|
||||
|
||||
oldStyle = client->exp != NULL && !client->tlscreds;
|
||||
if (oldStyle) {
|
||||
assert ((client->exp->nbdflags & ~65535) == 0);
|
||||
TRACE("advertising size %" PRIu64 " and flags %x",
|
||||
client->exp->size, client->exp->nbdflags | myflags);
|
||||
stq_be_p(buf + 8, NBD_CLIENT_MAGIC);
|
||||
@@ -606,7 +605,6 @@ static coroutine_fn int nbd_negotiate(NBDClientNewData *data)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
assert ((client->exp->nbdflags & ~65535) == 0);
|
||||
TRACE("advertising size %" PRIu64 " and flags %x",
|
||||
client->exp->size, client->exp->nbdflags | myflags);
|
||||
stq_be_p(buf + 18, client->exp->size);
|
||||
@@ -810,7 +808,7 @@ static void nbd_eject_notifier(Notifier *n, void *data)
|
||||
}
|
||||
|
||||
NBDExport *nbd_export_new(BlockBackend *blk, off_t dev_offset, off_t size,
|
||||
uint32_t nbdflags, void (*close)(NBDExport *),
|
||||
uint16_t nbdflags, void (*close)(NBDExport *),
|
||||
Error **errp)
|
||||
{
|
||||
NBDExport *exp = g_malloc0(sizeof(NBDExport));
|
||||
@@ -1057,7 +1055,8 @@ static ssize_t nbd_co_receive_request(NBDRequest *req,
|
||||
if (request->type & ~NBD_CMD_MASK_COMMAND & ~NBD_CMD_FLAG_FUA) {
|
||||
LOG("unsupported flags (got 0x%x)",
|
||||
request->type & ~NBD_CMD_MASK_COMMAND);
|
||||
return -EINVAL;
|
||||
rc = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
rc = 0;
|
||||
|
||||
@@ -463,6 +463,7 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
|
||||
exit(1);
|
||||
}
|
||||
|
||||
host_memory_backend_set_mapped(backend, true);
|
||||
memory_region_add_subregion(mr, addr, seg);
|
||||
vmstate_register_ram_global(seg);
|
||||
addr += size;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user