<div dir="ltr"><div>  My name is Tucker DiNapoli and I am working on implementing job control for<br>the storage driver for the google summer of code, the first step in doing this<br>is creating and implementing a unified api for job control.<br>
<br>Currently there are several places where various aspects of job control are<br>implemented. The qemu and libxl drivers both contain internal implementations<br>for job control on domain level jobs, with the qemu driver containing support<br>
for asynchronous jobs. There is also code in the libvirt.c file for running<br>block jobs and for querying domain jobs for information.<br><br>I would like for the job control api to be as independent of different drivers<br>
as possible since it will need to be used with storage drivers as well as<br>different virtualization drivers.<br><br>I imagine most of the api will revolve around a job object, and I think it's<br>important to decide what exactly should go in this job object.<br>
<br>This is a response from my first post on the mailing list and I think this is a<br>good idea.<br><br>>>I'd _really_ like to see a common notion of a 'job id' that EVERY job<br>>>(whether domain-level, like migration; or block-level, like<br>
>>commit/pull/rebase; or storage-level, like your new proposed storage<br>>>jobs) shares a common job namespace.  The job id is a positive integer.<br>>> Existing APIs will have to be retrofitted into the new job id notion;<br>
>>any action that starts a long-running job that currently returns 0 on<br>>>success could be changed to return a positive job id; or we may need a<br>>>new API that queries the notion of the 'current job' (the job most<br>
>>recently started) or even to set the 'current job' to a different job<br>>>id.  We'll need new API for querying a job by id, and to be most<br>>>portable, we should do job reporting via virTypedParameter<br>
>>(virDomainGetJobInfo and virDomainGetBlockJobInfo are hardcoded into<br>>>returning a struct, so they are non-extensible; virDomainGetJobStats<br>>>almost did it right, except that the user has to call it twice, once to<br>
>>learn how large to allocate, and again to pass in pre-allocated memory -<br>>>the ideal API would allocate the memory on a single call).<br><br>Currently there are separate types for block job info and job info, if possible<br>
I would like to merge these into a common job info type, and perhaps make this<br>a part of the job object itself.<br><br>Currently (in libxl and qemu) jobs are a part of the domain struct, I think<br>that jobs should be moved out of the domain struct instead using the idea of<br>
job ids for domains to keep track of currently running jobs. I'm still new to<br>libvirt so it this doesn't make sense and the idea of keeping job objects<br>attached to domains makes sense that's fine.<br><br>
I think at the minimum each job object should contain: the id of the thread<br>running the job, the type of job, the job id, a condition variable to<br>coordinate jobs, and information about the job, either as a separate job info<br>
object or as part of the job object itself. The job should also contain a<br>reference to the domain or storage it is associated with.<br><br>There are a few basic functions that should definitely be part of the api:<br>initialize a job, free a job, start a job, end a job, abort a job and get info<br>
on a job. It would be nice to be able to suspend a job and to change the<br>currently running job as well. That's what I can come up with, but I don't have<br>much experience in libvirt so if there are other features that make sense they<br>
can be added as well.<br><br>Finally (as far as I can think of right now) is the idea of parallel<br>jobs. Currently the qemu driver allows some jobs to be run in parallel by<br>allowing a job to be run asynchronously, this async job has a mask of job types<br>
associated with it that determine what types of regular jobs can be run during<br>it. However I would like to allow an arbitrary number of jobs to be run at once<br>(I'm not sure how useful this would be, but it seems best not to impose hard<br>
limits on things). The easiest way to deal with this is to just ignore it and<br>put the burden of synchronizing jobs on the drivers. This is obviously a bad<br>solution. Another way would be the way it is currently done it the qemu driver,<br>
have a mask of job types associated with each domain/storage which is updated<br>when a job is started or ended which dictates what types of jobs can be<br>started. Regardless of how this is done it will require support from the<br>
driver/domain/storage that each job is associated with.<br><br></div>Tucker DINapoli<br></div>