Bug 833769 - update virDomainDef with xml config.
Summary: update virDomainDef with xml config.
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Libvirt Maintainers
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-06-20 10:32 UTC by xuanmao
Modified: 2012-06-20 11:00 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-06-20 11:00:13 UTC
Embargoed:


Attachments (Terms of Use)

Description xuanmao 2012-06-20 10:32:22 UTC
Libvirt Version: 0.9.8

Hi:
   I added a new api for qemu_driver. and both added libvirt.c and remote.
I tested it and it worked well. the function of this new api was add a new field in xml config of domain. (I added it like qemudDomainSetMemoryFlags)at the same time, I added a new member to struct virDomainDef. then I tested xml config converted to virDomaindef and virDomainDef converted to xml config both well(just tested this new api). But there was a problem, if I change the memory size or cpu number then apply it with virtManager. the xml config was changed. but there is no field in the xml what I added. I guest the virDomainDef member in virDomainObjPtr wasn't update. 

I have no idea, can you give me some ideas? thanks!

here is my code in qemu_driver.c:

static int qemudDomainSetCustomOptions(virDomainPtr dom, char *opt)
{
    struct qemud_driver *driver = dom->conn->privateData;
    virDomainObjPtr vm;
    virDomainDefPtr persistentDef = NULL; 
    int ret = -1;  

    qemuDriverLock(driver);
    vm = virDomainFindByUUID(&driver->domains, dom->uuid);
    qemuDriverUnlock(driver);

    if (!vm) {
	char uuidstr[VIR_UUID_STRING_BUFLEN];
	virUUIDFormat(dom->uuid, uuidstr);
	qemuReportError(VIR_ERR_NO_DOMAIN,
		_("no domain with matching uuid '%s'"), uuidstr);
	    goto cleanup;
    }

    if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
	goto cleanup;

    if (!vm->persistent) {
	qemuReportError(VIR_ERR_OPERATION_INVALID, "%s",
	    _("cannot change persistent config of a transient domain"));
	goto endjob;
    }
	
    if (!(persistentDef = virDomainObjGetPersistentDef(driver->caps, vm)))
	goto endjob;
		
    sa_assert(persistentDef);

    persistentDef->running_mode = opt;

    ret = virDomainSaveConfig(driver->configDir, persistentDef);

    ret = 0;
endjob:
    if (qemuDomainObjEndJob(driver, vm) == 0)
	vm = NULL;

cleanup:
    if (vm)
	virDomainObjUnlock(vm);
	return ret;
}

Comment 1 Daniel Berrangé 2012-06-20 11:00:13 UTC
Bugzilla is not the right place to hold discussions about how to understand libvirt code internals. Please take your questions to the llibvirt developers mailing list as mentioned here:

http://libvirt.org/contact.html


Note You need to log in before you can comment on or make changes to this bug.