45 lines
1.7 KiB
Diff
45 lines
1.7 KiB
Diff
|
|
From aa0f9438a27ad4ae2086d49b70d72def2f9f9024 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Wei Gao <gaowei66@huawei.com>
|
||
|
|
Date: Thu, 26 Aug 2021 10:50:43 +0800
|
||
|
|
Subject: [PATCH 03/10] migration: add dev_id into VirtioPciState when save and
|
||
|
|
restore device state.
|
||
|
|
|
||
|
|
After commit 94c7bfbeeacda20d488b7ad2ad4fa9293f5883b4, pci device's dev_id will be reallocated when device activated or reset. So it's necessary to save dev_id during migration.
|
||
|
|
|
||
|
|
Signed-off-by: Wei Gao <gaowei66@huawei.com>
|
||
|
|
---
|
||
|
|
virtio/src/virtio_pci.rs | 3 +++
|
||
|
|
1 file changed, 3 insertions(+)
|
||
|
|
|
||
|
|
diff --git a/virtio/src/virtio_pci.rs b/virtio/src/virtio_pci.rs
|
||
|
|
index aaf009e..8bdfce6 100644
|
||
|
|
--- a/virtio/src/virtio_pci.rs
|
||
|
|
+++ b/virtio/src/virtio_pci.rs
|
||
|
|
@@ -439,6 +439,7 @@ impl Clone for NotifyEventFds {
|
||
|
|
#[desc_version(compat_version = "0.1.0")]
|
||
|
|
pub struct VirtioPciState {
|
||
|
|
activated: bool,
|
||
|
|
+ dev_id: u16,
|
||
|
|
/// Max length of config_space is 4096.
|
||
|
|
config_space: [u8; 4096],
|
||
|
|
write_mask: [u8; 4096],
|
||
|
|
@@ -1040,6 +1041,7 @@ impl StateTransfer for VirtioPciDevice {
|
||
|
|
|
||
|
|
// Save virtio pci state.
|
||
|
|
state.activated = self.device_activated.load(Ordering::Relaxed);
|
||
|
|
+ state.dev_id = self.dev_id.load(Ordering::Acquire);
|
||
|
|
{
|
||
|
|
let locked_queues = self.queues.lock().unwrap();
|
||
|
|
for (index, queue) in locked_queues.iter().enumerate() {
|
||
|
|
@@ -1083,6 +1085,7 @@ impl StateTransfer for VirtioPciDevice {
|
||
|
|
// Set virtio pci state.
|
||
|
|
self.device_activated
|
||
|
|
.store(pci_state.activated, Ordering::Relaxed);
|
||
|
|
+ self.dev_id.store(pci_state.dev_id, Ordering::Release);
|
||
|
|
{
|
||
|
|
let queue_type = self.common_config.lock().unwrap().queue_type;
|
||
|
|
let mut locked_queues = self.queues.lock().unwrap();
|
||
|
|
--
|
||
|
|
2.25.1
|
||
|
|
|