[libvirt] [PATCH 2/6] test: Break out wrapper for setting up started domain state.

Daniel P. Berrange berrange at redhat.com
Tue Nov 3 20:58:17 UTC 2009


On Mon, Nov 02, 2009 at 03:02:43PM -0500, Cole Robinson wrote:
> This should be a no op for now, but we will use this function to set up
> transient state in the future.
> 
> Signed-off-by: Cole Robinson <crobinso at redhat.com>
> ---
>  src/test/test_driver.c |   42 ++++++++++++++++++++++++++++++++----------
>  1 files changed, 32 insertions(+), 10 deletions(-)
> 
> diff --git a/src/test/test_driver.c b/src/test/test_driver.c
> index 2c61cf1..8472e27 100644
> --- a/src/test/test_driver.c
> +++ b/src/test/test_driver.c
> @@ -325,6 +325,17 @@ testDomainGenerateIfnames(virConnectPtr conn,
>      return 0;
>  }
>  
> +static int
> +testDomainStartState(virConnectPtr conn,
> +                     virDomainObjPtr dom)
> +{
> +    testConnPtr privconn = conn->privateData;
> +
> +    dom->state = VIR_DOMAIN_RUNNING;
> +    dom->def->id = privconn->nextDomID++;
> +
> +    return 0;
> +}
>  
>  static int testOpenDefault(virConnectPtr conn) {
>      int u;
> @@ -391,8 +402,12 @@ static int testOpenDefault(virConnectPtr conn) {
>                                        &privconn->domains, domdef)))
>          goto error;
>      domdef = NULL;
> -    domobj->def->id = privconn->nextDomID++;
> -    domobj->state = VIR_DOMAIN_RUNNING;
> +
> +    if (testDomainStartState(conn, domobj) < 0) {
> +        virDomainObjUnlock(domobj);
> +        goto error;
> +    }
> +
>      domobj->persistent = 1;
>      virDomainObjUnlock(domobj);
>  
> @@ -746,8 +761,11 @@ static int testOpenFromFile(virConnectPtr conn,
>              goto error;
>          }
>  
> -        dom->state = VIR_DOMAIN_RUNNING;
> -        dom->def->id = privconn->nextDomID++;
> +        if (testDomainStartState(conn, dom) < 0) {
> +            virDomainObjUnlock(dom);
> +            goto error;
> +        }
> +
>          dom->persistent = 1;
>          virDomainObjUnlock(dom);
>      }
> @@ -1083,8 +1101,9 @@ testDomainCreateXML(virConnectPtr conn, const char *xml,
>                                     &privconn->domains, def)))
>          goto cleanup;
>      def = NULL;
> -    dom->state = VIR_DOMAIN_RUNNING;
> -    dom->def->id = privconn->nextDomID++;
> +
> +    if (testDomainStartState(conn, dom) < 0)
> +        goto cleanup;
>  
>      event = virDomainEventNewFromObj(dom,
>                                       VIR_DOMAIN_EVENT_STARTED,
> @@ -1633,8 +1652,9 @@ static int testDomainRestore(virConnectPtr conn,
>          goto cleanup;
>      def = NULL;
>  
> -    dom->state = VIR_DOMAIN_RUNNING;
> -    dom->def->id = privconn->nextDomID++;
> +    if (testDomainStartState(conn, dom) < 0)
> +        goto cleanup;
> +
>      event = virDomainEventNewFromObj(dom,
>                                       VIR_DOMAIN_EVENT_STARTED,
>                                       VIR_DOMAIN_EVENT_STARTED_RESTORED);
> @@ -1993,8 +2013,10 @@ static int testDomainCreate(virDomainPtr domain) {
>          goto cleanup;
>      }
>  
> -    domain->id = privdom->def->id = privconn->nextDomID++;
> -    privdom->state = VIR_DOMAIN_RUNNING;
> +    if (testDomainStartState(domain->conn, privdom) < 0)
> +        goto cleanup;
> +    domain->id = privdom->def->id;
> +
>      event = virDomainEventNewFromObj(privdom,
>                                       VIR_DOMAIN_EVENT_STARTED,
>                                       VIR_DOMAIN_EVENT_STARTED_BOOTED);

ACK


Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list