On 17/01/2023 12:31, David Woodhouse wrote:
On Tue, 2023-01-17 at 11:11 +0000, Paul Durrant wrote:

Ick. Do we really want cross-block gotos? For me it would look a lot
nicer if you did a forward jump here and later and put the label+code
after the `return 0`.

How's this?

From my PoV, much better. Thanks.


static int set_vcpu_info(CPUState *cs, uint64_t gpa)
{
     X86CPU *cpu = X86_CPU(cs);
     CPUX86State *env = &cpu->env;
     MemoryRegionSection mrs = { .mr = NULL };
     void *vcpu_info_hva = NULL;
     int ret;

     ret = kvm_xen_set_vcpu_attr(cs, KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO, gpa);
     if (ret || gpa == INVALID_GPA) {
         goto out;
     }

     mrs = memory_region_find(get_system_memory(), gpa, sizeof(struct 
vcpu_info));
     if (!mrs.mr) {
         ret = -EINVAL;
     } else if (!mrs.mr->ram_block || mrs.size < sizeof(struct vcpu_info) ||
                !(vcpu_info_hva = qemu_map_ram_ptr(mrs.mr->ram_block,
                                                   mrs.offset_within_region))) {
         ret = -EINVAL;
         memory_region_unref(mrs.mr);
         mrs.mr = NULL;
     }

  out:
     if (env->xen_vcpu_info_mr) {
         memory_region_unref(env->xen_vcpu_info_mr);
     }
     env->xen_vcpu_info_hva = vcpu_info_hva;
     env->xen_vcpu_info_mr = mrs.mr;
     return ret;
}




Reply via email to