On 7/28/2021 12:56 AM, Zheng Chuan wrote:
> On 2021/7/8 1:20, Steve Sistare wrote:
>> Enable vfio-pci devices to be saved and restored across an exec restart
>> of qemu.
>>
>> [...]
>> --- a/migration/cpr.c
>> +++ b/migration/cpr.c
>> @@ -31,6 +31,13 @@
>>  #include "hw/virtio/vhost.h"
>>  #include "qemu/env.h"
>>  
>> +static CprMode cpr_active_mode = CPR_MODE_NONE;
>> +
>> +CprMode cpr_mode(void)
>> +{
>> +    return cpr_active_mode;
>> +}
>> +
>>  QEMUFile *qf_file_open(const char *path, int flags, int mode,
>>                                const char *name, Error **errp)
>>  {
>> @@ -92,6 +99,7 @@ void cprsave(const char *file, CprMode mode, Error **errp)
>>      }
>>      vm_stop(RUN_STATE_SAVE_VM);
>>  
>> +    cpr_active_mode = mode;
>>      ret = qemu_save_device_state(f);
>>      qemu_fclose(f);
>>      if (ret < 0) {
>> @@ -105,6 +113,7 @@ err:
>>      if (saved_vm_running) {
>>          vm_start();
>>      }
>> +    cpr_active_mode = CPR_MODE_NONE;
>>  done:
>>      return;
>>  }
>> @@ -125,6 +134,13 @@ void cprexec(strList *args, Error **errp)
>>          error_setg(errp, "runstate is not save-vm");
>>          return;
>>      }
>> +    if (cpr_active_mode != CPR_MODE_RESTART) {
>> +        error_setg(errp, "cprexec requires cprsave with restart mode");
>> +        return;
>> +    }
>> +    if (vfio_cprsave(errp)) {
>> +        return;
>> +    }
>>      walkenv(FD_PREFIX, preserve_fd, 0);
>>      qemu_system_exec_request(args);
>>  }
>> @@ -158,6 +174,10 @@ void cprload(const char *file, Error **errp)
>>          return;
>>      }
>>  
>> +    if (vfio_cprload(errp)) {
>> +        return;
>> +    }
>> +
> It will compile failed in some targets without vfio support such as m68k.
> Maybe CONFIG_VFIO should be added for vfio_{save, load}.
> 
>>      state = global_state_get_runstate();
>>      if (state == RUN_STATE_RUNNING) {
>>          vm_start();

Thank-you Zheng.  I will fix this and the other mistakes you found.

- Steve

Reply via email to