A habeas corpus petition attacking a criminal conviction or sentence shall be filed within two years from the date of final judgment in the trial court. First, the petitioner must be in custody under Virginia law, meaning either incarcerated or under a suspended sentence and the like.All other petitions for a writ of habeas corpus must be filed within one year after the cause of action accrues. (2) What the Petition Must Contain. A petition for a writ of habeas corpus is a case filed in court, either state or federal court depending on jurisdiction. § 2254 allows us to file a petition for Habeas Corpus when the client is in custody under sentence of a state court and is in a state prison. Generally, anyone detained or imprisoned can file a petition for a writ of habeas corpus in the United States. Straint in the North Carolina detainer which was filed with the Virginia prison officials and the Virginia commitment. The "sine qua non" of habeas corpus jurisdiction is custody. The law in the area is an intricate weave of statute and case law.