Skip to contentSkip to conversation

migration queue

GIT PULL Applied Dr. David Alan Gilbert (git) 2 participants 7 messages Aug 2, 2022

lore
Share & tools
lore
#0 lore raw

From: "Dr. David Alan Gilbert" <[email protected]>

The following changes since commit 0399521e53336bd2cdc15482bca0ffd3493fdff6:

Merge tag 'for-upstream' of git://repo.or.cz/qemu/kevin into staging (2022-08-02 06:52:05 -0700)

are available in the Git repository at:

https://gitlab.com/dagrh/qemu.git tags/pull-migration-20220802c

for you to fetch changes up to a21ba54dd5ca38cd05da9035fc65374d7af54f13:

virtiofsd: Disable killpriv_v2 by default (2022-08-02 16:46:52 +0100)

----------------------------------------------------------------
Migration fixes pull 2022-08-02

Small migration (and virtiofsd) fixes.

----------------------------------------------------------------
Leonardo Bras (1):

      migration: add remaining params->has_* = true in migration_instance_init()

Peter Maydell (2):
migration: Assert that migrate_multifd_compression() returns an in-range value
migration: Define BLK_MIG_BLOCK_SIZE as unsigned long long

Thomas Huth (1):
Revert "migration: Simplify unqueue_page()"

Vivek Goyal (1):
virtiofsd: Disable killpriv_v2 by default

 migration/block.c                |  2 +-
 migration/migration.c            |  5 +++++
 migration/ram.c                  | 37 ++++++++++++++++++++++++++-----------
 migration/trace-events           |  3 ++-
 tools/virtiofsd/passthrough_ll.c | 13 ++-----------
 5 files changed, 36 insertions(+), 24 deletions(-)
#1 lore raw

[PULL 3/5] migration: Assert that migrate_multifd_compression() returns an in-range value

From: Peter Maydell <[email protected]>

Coverity complains that when we use the return value from migrate_multifd_compression() as an array index:
multifd_recv_state->ops = multifd_ops[migrate_multifd_compression()];

that this might overrun the array (which is declared to have size MULTIFD_COMPRESSION__MAX). This is because the function return type is MultiFDCompression, which is an autogenerated enum. The code generator includes the "one greater than the maximum possible value" MULTIFD_COMPRESSION__MAX in the enum, even though this is not actually a valid value for the enum, and this makes Coverity think that migrate_multifd_compression() could return that __MAX value and index off the end of the array.

Suppress the Coverity error by asserting that the value we're going to return is within range.

Resolves: Coverity CID 1487239, 1487254

Message-Id: <[email protected]>

---
 migration/migration.c | 1 +
 1 file changed, 1 insertion(+)
migration/migration.c +1 -0
index 82fbe0cf55..bb8bbddfe4 100644
@@ -2617,6 +2617,7 @@ MultiFDCompression migrate_multifd_compression(void)
 
     s = migrate_get_current();
 
+    assert(s->parameters.multifd_compression < MULTIFD_COMPRESSION__MAX);
     return s->parameters.multifd_compression;
 }
 
Signature · 1 line
2.37.1
#2 lore raw

[PULL 2/5] Revert "migration: Simplify unqueue_page()"

In reply to Dr. David Alan Gilbert (git)

From: Thomas Huth <[email protected]>

This reverts commit cfd66f30fb0f735df06ff4220e5000290a43dad3.

The simplification of unqueue_page() introduced a bug that sometimes breaks migration on s390x hosts.

The problem is not fully understood yet, but since we are already in the freeze for QEMU 7.1 and we need something working there, let's revert this patch for the upcoming release. The optimization can be redone later again in a proper way if necessary.

Message-Id: <[email protected]>

---
 migration/ram.c        | 37 ++++++++++++++++++++++++++-----------
 migration/trace-events |  3 ++-
 2 files changed, 28 insertions(+), 12 deletions(-)
migration/ram.c +26 -11
index b94669ba5d..dc1de9ddbc 100644
@@ -1612,7 +1612,6 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset)
 {
     struct RAMSrcPageRequest *entry;
     RAMBlock *block = NULL;
-    size_t page_size;
 
     if (!postcopy_has_request(rs)) {
         return NULL;
@@ -1629,13 +1628,10 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset)
     entry = QSIMPLEQ_FIRST(&rs->src_page_requests);
     block = entry->rb;
     *offset = entry->offset;
-    page_size = qemu_ram_pagesize(block);
-    /* Each page request should only be multiple page size of the ramblock */
-    assert((entry->len % page_size) == 0);
 
-    if (entry->len > page_size) {
-        entry->len -= page_size;
-        entry->offset += page_size;
+    if (entry->len > TARGET_PAGE_SIZE) {
+        entry->len -= TARGET_PAGE_SIZE;
+        entry->offset += TARGET_PAGE_SIZE;
     } else {
         memory_region_unref(block->mr);
         QSIMPLEQ_REMOVE_HEAD(&rs->src_page_requests, next_req);
@@ -1643,9 +1639,6 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset)
         migration_consume_urgent_request();
     }
 
-    trace_unqueue_page(block->idstr, *offset,
-                       test_bit((*offset >> TARGET_PAGE_BITS), block->bmap));
-
     return block;
 }
 
@@ -2069,8 +2062,30 @@ static bool get_queued_page(RAMState *rs, PageSearchStatus *pss)
 {
     RAMBlock  *block;
     ram_addr_t offset;
+    bool dirty;
+
+    do {
+        block = unqueue_page(rs, &offset);
+        /*
+         * We're sending this page, and since it's postcopy nothing else
+         * will dirty it, and we must make sure it doesn't get sent again
+         * even if this queue request was received after the background
+         * search already sent it.
+         */
+        if (block) {
+            unsigned long page;
+
+            page = offset >> TARGET_PAGE_BITS;
+            dirty = test_bit(page, block->bmap);
+            if (!dirty) {
+                trace_get_queued_page_not_dirty(block->idstr, (uint64_t)offset,
+                                                page);
+            } else {
+                trace_get_queued_page(block->idstr, (uint64_t)offset, page);
+            }
+        }
 
-    block = unqueue_page(rs, &offset);
+    } while (block && !dirty);
 
     if (block) {
         /* See comment above postcopy_preempted_contains() */
migration/trace-events +2 -1
index a34afe7b85..57003edcbd 100644
@@ -85,6 +85,8 @@ put_qlist_end(const char *field_name, const char *vmsd_name) "%s(%s)"
 qemu_file_fclose(void) ""
 
 # ram.c
+get_queued_page(const char *block_name, uint64_t tmp_offset, unsigned long page_abs) "%s/0x%" PRIx64 " page_abs=0x%lx"
+get_queued_page_not_dirty(const char *block_name, uint64_t tmp_offset, unsigned long page_abs) "%s/0x%" PRIx64 " page_abs=0x%lx"
 migration_bitmap_sync_start(void) ""
 migration_bitmap_sync_end(uint64_t dirty_pages) "dirty_pages %" PRIu64
 migration_bitmap_clear_dirty(char *str, uint64_t start, uint64_t size, unsigned long page) "rb %s start 0x%"PRIx64" size 0x%"PRIx64" page 0x%lx"
@@ -110,7 +112,6 @@ ram_save_iterate_big_wait(uint64_t milliconds, int iterations) "big wait: %" PRI
 ram_load_complete(int ret, uint64_t seq_iter) "exit_code %d seq iteration %" PRIu64
 ram_write_tracking_ramblock_start(const char *block_id, size_t page_size, void *addr, size_t length) "%s: page_size: %zu addr: %p length: %zu"
 ram_write_tracking_ramblock_stop(const char *block_id, size_t page_size, void *addr, size_t length) "%s: page_size: %zu addr: %p length: %zu"
-unqueue_page(char *block, uint64_t offset, bool dirty) "ramblock '%s' offset 0x%"PRIx64" dirty %d"
 postcopy_preempt_triggered(char *str, unsigned long page) "during sending ramblock %s offset 0x%lx"
 postcopy_preempt_restored(char *str, unsigned long page) "ramblock %s offset 0x%lx"
 postcopy_preempt_hit(char *str, uint64_t offset) "ramblock %s offset 0x%"PRIx64
Signature · 1 line
2.37.1
#3 lore raw

[PULL 1/5] migration: add remaining params->has_* = true in migration_instance_init()

In reply to Dr. David Alan Gilbert (git)

From: Leonardo Bras <[email protected]>

Some of params->has_* = true are missing in migration_instance_init, this causes migrate_params_check() to skip some tests, allowing some unsupported scenarios.

Fix this by adding all missing params->has_* = true in migration_instance_init().

Fixes 69ef1f36b0 ("migration: define 'tls-creds' and 'tls-hostname' migration parameters")
Fixes 1d58872a91 ("migration: do not wait for free thread")
Fixes d2f1d29b95 ("migration: add support for a "tls-authz" migration parameter")

Message-Id: <[email protected]>

---
 migration/migration.c | 4 ++++
 1 file changed, 4 insertions(+)
migration/migration.c +4 -0
index e03f698a3c..82fbe0cf55 100644
@@ -4451,6 +4451,7 @@ static void migration_instance_init(Object *obj)
     /* Set has_* up only for parameter checks */
     params->has_compress_level = true;
     params->has_compress_threads = true;
+    params->has_compress_wait_thread = true;
     params->has_decompress_threads = true;
     params->has_throttle_trigger_threshold = true;
     params->has_cpu_throttle_initial = true;
@@ -4471,6 +4472,9 @@ static void migration_instance_init(Object *obj)
     params->has_announce_max = true;
     params->has_announce_rounds = true;
     params->has_announce_step = true;
+    params->has_tls_creds = true;
+    params->has_tls_hostname = true;
+    params->has_tls_authz = true;
 
     qemu_sem_init(&ms->postcopy_pause_sem, 0);
     qemu_sem_init(&ms->postcopy_pause_rp_sem, 0);
Signature · 1 line
2.37.1
#4 lore raw

[PULL 4/5] migration: Define BLK_MIG_BLOCK_SIZE as unsigned long long

In reply to Dr. David Alan Gilbert (git)

From: Peter Maydell <[email protected]>

When we use BLK_MIG_BLOCK_SIZE in expressions like block_mig_state.submitted * BLK_MIG_BLOCK_SIZE, this multiplication is done as 32 bits, because both operands are 32 bits. Coverity complains about possible overflows because we then accumulate that into a 64 bit variable.

Define BLK_MIG_BLOCK_SIZE as unsigned long long using the ULL suffix. The only two current uses of it with this problem are both in block_save_pending(), so we could just cast to uint64_t there, but using the ULL suffix is simpler and ensures that we don't accidentally introduce new variants of the same issue in future.

Resolves: Coverity CID 1487136, 1487175

Message-Id: <[email protected]>

---
 migration/block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
migration/block.c +1 -1
index 9e5aae5898..3577c815a9 100644
@@ -28,7 +28,7 @@
 #include "sysemu/block-backend.h"
 #include "trace.h"
 
-#define BLK_MIG_BLOCK_SIZE           (1 << 20)
+#define BLK_MIG_BLOCK_SIZE           (1ULL << 20)
 #define BDRV_SECTORS_PER_DIRTY_CHUNK (BLK_MIG_BLOCK_SIZE >> BDRV_SECTOR_BITS)
 
 #define BLK_MIG_FLAG_DEVICE_BLOCK       0x01
Signature · 1 line
2.37.1
#5 lore raw

[PULL 5/5] virtiofsd: Disable killpriv_v2 by default

In reply to Dr. David Alan Gilbert (git)

From: Vivek Goyal <[email protected]>

We are having bunch of issues with killpriv_v2 enabled by default. First of all it relies on clearing suid/sgid bits as needed by dropping capability CAP_FSETID. This does not work for remote filesystems like NFS (and possibly others).

Secondly, we are noticing other issues related to clearing of SGID which leads to failures for xfstests generic/355 and generic/193.

Thirdly, there are other issues w.r.t caching of metadata (suid/sgid) bits in fuse client with killpriv_v2 enabled. Guest can cache that data for sometime even if cleared on server.

Second and Third issue are fixable. Just that it might take a little while to get it fixed in kernel. First one will probably not see any movement for a long time.

Given these issues, killpriv_v2 does not seem to be a good candidate for enabling by default. We have already disabled it by default in rust version of virtiofsd.

Hence this patch disabled killpriv_v2 by default. User can choose to enable it by passing option "-o killpriv_v2".

Message-Id: <[email protected]>

---
 tools/virtiofsd/passthrough_ll.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)
tools/virtiofsd/passthrough_ll.c +2 -11
index 7a73dfcce9..371a7bead6 100644
@@ -767,19 +767,10 @@ static void lo_init(void *userdata, struct fuse_conn_info *conn)
         fuse_log(FUSE_LOG_DEBUG, "lo_init: enabling killpriv_v2\n");
         conn->want |= FUSE_CAP_HANDLE_KILLPRIV_V2;
         lo->killpriv_v2 = 1;
-    } else if (lo->user_killpriv_v2 == -1 &&
-               conn->capable & FUSE_CAP_HANDLE_KILLPRIV_V2) {
-        /*
-         * User did not specify a value for killpriv_v2. By default enable it
-         * if connection offers this capability
-         */
-        fuse_log(FUSE_LOG_DEBUG, "lo_init: enabling killpriv_v2\n");
-        conn->want |= FUSE_CAP_HANDLE_KILLPRIV_V2;
-        lo->killpriv_v2 = 1;
     } else {
         /*
-         * Either user specified to disable killpriv_v2, or connection does
-         * not offer this capability. Disable killpriv_v2 in both the cases
+         * Either user specified to disable killpriv_v2, or did not
+         * specify anything. Disable killpriv_v2 in both the cases.
          */
         fuse_log(FUSE_LOG_DEBUG, "lo_init: disabling killpriv_v2\n");
         conn->want &= ~FUSE_CAP_HANDLE_KILLPRIV_V2;
Signature · 1 line
2.37.1
#6 lore raw
In reply to Dr. David Alan Gilbert (git)
Quoted 10 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

The following changes since commit 0399521e53336bd2cdc15482bca0ffd3493fdff6:

   Merge tag 'for-upstream' of git://repo.or.cz/qemu/kevin into staging (2022-08-02 06:52:05 -0700)

are available in the Git repository at:

   https://gitlab.com/dagrh/qemu.git tags/pull-migration-20220802c
Quoted 8 lines

for you to fetch changes up to a21ba54dd5ca38cd05da9035fc65374d7af54f13:

   virtiofsd: Disable killpriv_v2 by default (2022-08-02 16:46:52 +0100)

----------------------------------------------------------------
Migration fixes pull 2022-08-02

Small migration (and virtiofsd) fixes.

Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/7.1 as appropriate.

r~

Quoted 25 lines

----------------------------------------------------------------
Leonardo Bras (1):

       migration: add remaining params->has_* = true in migration_instance_init()

Peter Maydell (2):
migration: Assert that migrate_multifd_compression() returns an in-range value
migration: Define BLK_MIG_BLOCK_SIZE as unsigned long long

Thomas Huth (1):
Revert "migration: Simplify unqueue_page()"

Vivek Goyal (1):
virtiofsd: Disable killpriv_v2 by default

  migration/block.c                |  2 +-
  migration/migration.c            |  5 +++++
  migration/ram.c                  | 37 ++++++++++++++++++++++++++-----------
  migration/trace-events           |  3 ++-
  tools/virtiofsd/passthrough_ll.c | 13 ++-----------
  5 files changed, 36 insertions(+), 24 deletions(-)