Bug fixes.

-----BEGIN PGP SIGNATURE-----
 
 iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAls/m2YUHHBib256aW5p
 QHJlZGhhdC5jb20ACgkQv/vSX3jHroPuoAf/V3cuuGPh2hWVrsXoFdHPcLINuxb6
 f45PaQ3wWj4W8KziUMloTpmNK08vjV/Jh6aDgG4pSNehUjvyTmaeHVJwQQ3Jk2DQ
 iPuL+aDEiCKht+B5mq0BBWoeaOHY4AgY8rvquZ1UZYOLC0Echn8ycf2sMhMFyM57
 /ah29vZ2Rk4/FK2zM5PLlwUxUxvLPhvm0gm8zXK6xQafi5YfR9Dz9C9u++8Sf2cA
 PBEu2rxvfHAoFDTqjUxW5UEb5xhpyAE8Pmr1y6pZrOxvkNgNcGeZpLJxzWUzUvdK
 zFVCJm0NNHDcnAZdzaRpLAOLXwHPUWezLBq2dHUn2NWParFvMdKnH62Hpg==
 =Xbyg
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging

Bug fixes.

# gpg: Signature made Fri 06 Jul 2018 17:40:06 BST
# gpg:                using RSA key BFFBD25F78C7AE83
# 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:
  checkpatch: handle token pasting better
  ioapic: remove useless lower bounds check
  pr-manager-helper: fix memory leak on event
  qemu-char: check errno together with ret < 0
  i386: fix '-cpu ?' output for host cpu type
  qtest: Use cpu address space instead of system memory
  pr-helper: Rework socket path handling
  pr-helper: avoid error on PR IN command with zero request size

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2018-07-06 18:18:08 +01:00
commit 43a473993f
7 changed files with 84 additions and 87 deletions

View File

@ -134,8 +134,11 @@ static int tcp_chr_write(Chardev *chr, const uint8_t *buf, int len)
s->write_msgfds,
s->write_msgfds_num);
/* free the written msgfds in any cases other than errno==EAGAIN */
if (EAGAIN != errno && s->write_msgfds_num) {
/* free the written msgfds in any cases
* other than ret < 0 && errno == EAGAIN
*/
if (!(ret < 0 && EAGAIN == errno)
&& s->write_msgfds_num) {
g_free(s->write_msgfds);
s->write_msgfds = 0;
s->write_msgfds_num = 0;

View File

@ -152,7 +152,7 @@ static void ioapic_set_irq(void *opaque, int vector, int level)
if (vector == 0) {
vector = 2;
}
if (vector >= 0 && vector < IOAPIC_NUM_PINS) {
if (vector < IOAPIC_NUM_PINS) {
uint32_t mask = 1 << vector;
uint64_t entry = s->ioredtbl[vector];

39
qtest.c
View File

@ -387,19 +387,23 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
if (words[0][5] == 'b') {
uint8_t data = value;
cpu_physical_memory_write(addr, &data, 1);
address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
&data, 1, true);
} else if (words[0][5] == 'w') {
uint16_t data = value;
tswap16s(&data);
cpu_physical_memory_write(addr, &data, 2);
address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
(uint8_t *) &data, 2, true);
} else if (words[0][5] == 'l') {
uint32_t data = value;
tswap32s(&data);
cpu_physical_memory_write(addr, &data, 4);
address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
(uint8_t *) &data, 4, true);
} else if (words[0][5] == 'q') {
uint64_t data = value;
tswap64s(&data);
cpu_physical_memory_write(addr, &data, 8);
address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
(uint8_t *) &data, 8, true);
}
qtest_send_prefix(chr);
qtest_send(chr, "OK\n");
@ -417,18 +421,22 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
if (words[0][4] == 'b') {
uint8_t data;
cpu_physical_memory_read(addr, &data, 1);
address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
&data, 1, false);
value = data;
} else if (words[0][4] == 'w') {
uint16_t data;
cpu_physical_memory_read(addr, &data, 2);
address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
(uint8_t *) &data, 2, false);
value = tswap16(data);
} else if (words[0][4] == 'l') {
uint32_t data;
cpu_physical_memory_read(addr, &data, 4);
address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
(uint8_t *) &data, 4, false);
value = tswap32(data);
} else if (words[0][4] == 'q') {
cpu_physical_memory_read(addr, &value, 8);
address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
(uint8_t *) &value, 8, false);
tswap64s(&value);
}
qtest_send_prefix(chr);
@ -448,7 +456,8 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
g_assert(len);
data = g_malloc(len);
cpu_physical_memory_read(addr, data, len);
address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
data, len, false);
enc = g_malloc(2 * len + 1);
for (i = 0; i < len; i++) {
@ -473,7 +482,8 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
g_assert(ret == 0);
data = g_malloc(len);
cpu_physical_memory_read(addr, data, len);
address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
data, len, false);
b64_data = g_base64_encode(data, len);
qtest_send_prefix(chr);
qtest_sendf(chr, "OK %s\n", b64_data);
@ -507,7 +517,8 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
data[i] = 0;
}
}
cpu_physical_memory_write(addr, data, len);
address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
data, len, true);
g_free(data);
qtest_send_prefix(chr);
@ -529,7 +540,8 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
if (len) {
data = g_malloc(len);
memset(data, pattern, len);
cpu_physical_memory_write(addr, data, len);
address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
data, len, true);
g_free(data);
}
@ -562,7 +574,8 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
out_len = MIN(out_len, len);
}
cpu_physical_memory_write(addr, data, out_len);
address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
data, len, true);
qtest_send_prefix(chr);
qtest_send(chr, "OK\n");

View File

@ -1132,11 +1132,10 @@ sub possible {
case|
else|
asm|__asm__|
do|
\#|
\#\#
do
)(?:\s|$)|
^(?:typedef|struct|enum)\b
^(?:typedef|struct|enum)\b|
^\#
)}x;
warn "CHECK<$possible> ($line)\n" if ($dbg_possible > 2);
if ($possible !~ $notPermitted) {
@ -1146,7 +1145,7 @@ sub possible {
if ($possible =~ /^\s*$/) {
} elsif ($possible =~ /\s/) {
$possible =~ s/\s*$Type\s*//g;
$possible =~ s/\s*(?:$Type|\#\#)\s*//g;
for my $modifier (split(' ', $possible)) {
if ($modifier !~ $notPermitted) {
warn "MODIFIER: $modifier ($possible) ($line)\n" if ($dbg_possible);

View File

@ -46,6 +46,7 @@ static void pr_manager_send_status_changed_event(PRManagerHelper *pr_mgr)
if (id) {
qapi_event_send_pr_manager_status_changed(id, !!pr_mgr->ioc,
&error_abort);
g_free(id);
}
}

View File

@ -76,14 +76,12 @@ static int gid = -1;
static void compute_default_paths(void)
{
if (!socket_path) {
socket_path = qemu_get_local_state_pathname("run/qemu-pr-helper.sock");
}
pidfile = qemu_get_local_state_pathname("run/qemu-pr-helper.pid");
}
static void usage(const char *name)
{
compute_default_paths();
(printf) (
"Usage: %s [OPTIONS] FILE\n"
"Persistent Reservation helper program for QEMU\n"
@ -455,6 +453,14 @@ static int multipath_pr_out(int fd, const uint8_t *cdb, uint8_t *sense,
char transportids[PR_HELPER_DATA_SIZE];
int r;
if (sz < PR_OUT_FIXED_PARAM_SIZE) {
/* Illegal request, Parameter list length error. This isn't fatal;
* we have read the data, send an error without closing the socket.
*/
scsi_build_sense(sense, SENSE_CODE(INVALID_PARAM_LEN));
return CHECK_CONDITION;
}
switch (rq_servact) {
case MPATH_PROUT_REG_SA:
case MPATH_PROUT_RES_SA:
@ -574,6 +580,12 @@ static int do_pr_out(int fd, const uint8_t *cdb, uint8_t *sense,
const uint8_t *param, int sz)
{
int resp_sz;
if ((fcntl(fd, F_GETFL) & O_ACCMODE) == O_RDONLY) {
scsi_build_sense(sense, SENSE_CODE(INVALID_OPCODE));
return CHECK_CONDITION;
}
#ifdef CONFIG_MPATH
if (is_mpath(fd)) {
return multipath_pr_out(fd, cdb, sense, param, sz);
@ -690,21 +702,6 @@ static int coroutine_fn prh_read_request(PRHelperClient *client,
errp) < 0) {
goto out_close;
}
if ((fcntl(client->fd, F_GETFL) & O_ACCMODE) == O_RDONLY) {
scsi_build_sense(resp->sense, SENSE_CODE(INVALID_OPCODE));
sz = 0;
} else if (sz < PR_OUT_FIXED_PARAM_SIZE) {
/* Illegal request, Parameter list length error. This isn't fatal;
* we have read the data, send an error without closing the socket.
*/
scsi_build_sense(resp->sense, SENSE_CODE(INVALID_PARAM_LEN));
sz = 0;
}
if (sz == 0) {
resp->result = CHECK_CONDITION;
close(client->fd);
client->fd = -1;
}
}
req->fd = client->fd;
@ -785,7 +782,6 @@ static void coroutine_fn prh_co_entry(void *opaque)
break;
}
if (sz > 0) {
num_active_sockets++;
if (req.cdb[0] == PERSISTENT_RESERVE_OUT) {
r = do_pr_out(req.fd, req.cdb, resp.sense,
@ -803,7 +799,6 @@ static void coroutine_fn prh_co_entry(void *opaque)
break;
}
resp.result = r;
}
if (prh_write_response(client, &req, &resp, &local_err) < 0) {
break;
@ -844,19 +839,6 @@ static gboolean accept_client(QIOChannel *ioc, GIOCondition cond, gpointer opaqu
return TRUE;
}
/*
* Check socket parameters compatibility when socket activation is used.
*/
static const char *socket_activation_validate_opts(void)
{
if (socket_path != NULL) {
return "Unix socket can't be set when using socket activation";
}
return NULL;
}
static void termsig_handler(int signum)
{
atomic_cmpxchg(&state, RUNNING, TERMINATE);
@ -930,6 +912,7 @@ int main(int argc, char **argv)
char *trace_file = NULL;
bool daemonize = false;
bool pidfile_specified = false;
bool socket_path_specified = false;
unsigned socket_activation;
struct sigaction sa_sigterm;
@ -946,12 +929,14 @@ int main(int argc, char **argv)
qemu_add_opts(&qemu_trace_opts);
qemu_init_exec_dir(argv[0]);
pidfile = qemu_get_local_state_pathname("run/qemu-pr-helper.pid");
compute_default_paths();
while ((ch = getopt_long(argc, argv, sopt, lopt, &opt_ind)) != -1) {
switch (ch) {
case 'k':
socket_path = optarg;
g_free(socket_path);
socket_path = g_strdup(optarg);
socket_path_specified = true;
if (socket_path[0] != '/') {
error_report("socket path must be absolute");
exit(EXIT_FAILURE);
@ -1042,10 +1027,9 @@ int main(int argc, char **argv)
socket_activation = check_socket_activation();
if (socket_activation == 0) {
SocketAddress saddr;
compute_default_paths();
saddr = (SocketAddress){
.type = SOCKET_ADDRESS_TYPE_UNIX,
.u.q_unix.path = g_strdup(socket_path)
.u.q_unix.path = socket_path,
};
server_ioc = qio_channel_socket_new();
if (qio_channel_socket_listen_sync(server_ioc, &saddr, &local_err) < 0) {
@ -1053,12 +1037,10 @@ int main(int argc, char **argv)
error_report_err(local_err);
return 1;
}
g_free(saddr.u.q_unix.path);
} else {
/* Using socket activation - check user didn't use -p etc. */
const char *err_msg = socket_activation_validate_opts();
if (err_msg != NULL) {
error_report("%s", err_msg);
if (socket_path_specified) {
error_report("Unix socket can't be set when using socket activation");
exit(EXIT_FAILURE);
}
@ -1075,7 +1057,6 @@ int main(int argc, char **argv)
error_get_pretty(local_err));
exit(EXIT_FAILURE);
}
socket_path = NULL;
}
if (qemu_init_main_loop(&local_err)) {

View File

@ -2836,13 +2836,13 @@ static void host_x86_cpu_class_init(ObjectClass *oc, void *data)
xcc->host_cpuid_required = true;
xcc->ordering = 8;
if (kvm_enabled()) {
#if defined(CONFIG_KVM)
xcc->model_description =
"KVM processor with all supported host features ";
} else if (hvf_enabled()) {
#elif defined(CONFIG_HVF)
xcc->model_description =
"HVF processor with all supported host features ";
}
#endif
}
static const TypeInfo host_x86_cpu_type_info = {